Problems? Is your data what you think it is? PerlMonks

### Re^4: Question on simple arithmetic using perl

by zwon (Abbot)
 on Sep 29, 2011 at 02:20 UTC ( #928456=note: print w/replies, xml ) Need Help??

Note that perl is actually using long and double. On 32bit double has more significant digits than long.

• Comment on Re^4: Question on simple arithmetic using perl

Replies are listed 'Best First'.
Re^5: Question on simple arithmetic using perl
by Marshall (Abbot) on Sep 29, 2011 at 03:29 UTC
Yes, if you mean that a 64 bit floating point number has more significant bits in the mantissa than a 32 bit integer does, I agree. I leave looking up the definition of ANSI C long and double to the interested readers.

Update: I looked up what Microsoft did for storage in C. "int" and "long" are both 32 bits (other folks will assign 64 bits to a "long"). A MS "float" is 32 bits and MS "double" is 64 bits with 52 bit mantissa.

ANSI C Summary says: that an int will have at least 4 significant decimal digits and a long will have at least 9 significant decimal digits (see link for exact ANSI spec'd ranges). An int can be the same size as a long (bigger than minimum is ok).

A float has to have 6 decimal digits of precision and a double has a minimum of 10 decimal digits of precision. So a double is guaranteed to have at least one more decimal digit of precision than a long (10 vs 9).

Create A New User
Node Status?
node history
Node Type: note [id://928456]
help
Chatterbox?
 [davido]: Lol, in composing test code for Re: Stupid, yet simple, sort question I managed to fill up /tmp for a moment, causing bash to complain about "pmbash: cannot create temp file for here-document: No space left on device" [davido]: hm, sorry, wrong link: Re^3: Perl Program to efficiently process 500000 small files in a Directory (AIX) should be it.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-03-18 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When I think of a mole I think of:

Results (228 votes). Check out past polls.

Notices?