Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Dealing with a large integer

Reply
Thread Tools

Dealing with a large integer

 
 
Mark McIntyre
Guest
Posts: n/a
 
      03-06-2006
On 6 Mar 2006 19:50:19 GMT, in comp.lang.c , Jordan Abel
<(E-Mail Removed)> wrote:

>Post code that you think safely uses gets and i'll prove it wrong within
>the context of the API you are using to "ensure" it.


This is such an easy challenge to defeat, I won't embarrass you.

>[well, i'm hoping
>you're using the unix api, since i wouldn't have the first clue about
>any other one]


Quite.
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
 
 
 
Mark McIntyre
Guest
Posts: n/a
 
      03-06-2006
On Mon, 06 Mar 2006 12:34:53 -0800, in comp.lang.c , Ben Pfaff
<(E-Mail Removed)> wrote:

>(E-Mail Removed)-cnrc.gc.ca (Walter Roberson) writes:
>
>> In article <(E-Mail Removed)>,
>> Jordan Abel <(E-Mail Removed)> wrote:
>>>Post code that you think safely uses gets and i'll prove it wrong within
>>>the context of the API you are using to "ensure" it. [well, i'm hoping
>>>you're using the unix api, since i wouldn't have the first clue about
>>>any other one]

>>
>> How about something like this:
>>
>> Open a file w+. Write known data into it. fseek() back to the
>> beginning of the file. gets() with a buffer at least as big as
>> the data to be written.

>
>gets() reads from stdin. You'll have to use freopen() to replace
>stdin by your file. Seems like a pretty big stretch to make just
>to use gets() safely, when you could just use a better designed
>function instead.


Nobody's arguing that its sensible to use gets(), merely with the
assertion that its "impossible" to use safely, even in a controlled
envrionment.

Heck if nuclear waste and anthrax can be safe, in the right
environment then ...
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
 
 
 
yong
Guest
Posts: n/a
 
      03-13-2006
russell kym horsell wrote:
> yong <(E-Mail Removed)> wrote:
>
>>Hi all
>>I have an large integer in this format

>
> [lemm call this X:]
>
>>x1*256^5 + x2*256^4 + x3*256^3 + x4*256^2 + x5*256 + x6
>>now I must convert it to this format

>
> [Y:]
>
>>y1*900^4 + y2*900^3 + y3*900^2 + y4*900 + y5
>>x1-x5 is given.I must get y1-y4 from it.
>>How can I do this on my 32bit PC?
>>Sorry for that my English is poor.
>>Thanks.

>
>
>
> Some kind of pdf encoder, eh?
>
>
> There's probably a lot of literature on smart tricks, but
> the basic idea (beside simply using 64-bit integers and brute force --
> BTW even 32-bit PC's can do h/w 64-bit arith these days) is to note that
>
> X % 900 = Y % 900 = y4.
>
> Then we see that
> 256^5 % 900 = 376
> 256^4 % 900 = 796
> 256^3 % 900 = 316
> 256^2 % 900 = 736
> 256^1 % 900 = 256
>
> So we must have y4 = (376*x1 + 796*x2 + 316*x3 + 736*x4 + 256*x5 + x6) % 900 .
> (Look, maw, only 16-bit arithmetic!)
>
> Similiarly for the other y_i.


Thanks.

It's really a good idea. :]

--
My Personal Weblog:
http://spaces.msn.com/cyberisblue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid Out of Memory Errors when dealing with a large XML file? Saqib Ali Perl Misc 2 01-14-2011 09:31 PM
Dealing with ctype.h integer overflow elitemx C Programming 0 06-28-2010 10:02 PM
Dealing with large memory under linux or How to Build 64bit Python proteusguy@gmail.com Python 1 01-22-2009 08:30 PM
dealing with large csv files brzak C++ 5 12-01-2008 12:00 PM
Pointers + dealing with integer arrays and strings Slain C++ 2 07-12-2007 01:09 PM



Advertisments