[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

re: [MacPerl] Basic question from a raw recruit



>} Now, a friend, who is an experienced programmer, but who doesn't know 
>} Perl, says it is because Perl is treating the number like an integer 
>} instead of a floating point number (probably because it IS an integer, 
>} having no decimal remainder).
>
>But Perl works very much like C (or Fortran for that matter) in these
>cases.  It sees that 1.07 is a float, so it knows it has to promote
>$gross to float to do the division properly no matter what it contains.

i thought Perl did *all* of its math in double precision. i know i've 
seen Larry post to that effect on c.l.p.*, but i can't seem to find that 
explicitly stated in the docs anywhere. i did find this from the 
description of pack() in the perlfunc man page:

"Note that Perl uses doubles internally for all numeric calculation, and 
converting from double into float and thence back to double again will 
lose precision (i.e. unpack("f", pack("f", $foo)) will not ingeneral 
equal $foo)."

and this footnote on page 65 of the Camel book:

"Perl stores numbers as double-precision floating-point values in the 
machine's native format."

--
Darin S. Morley
dmorley@stow.com
http://www.stow.com/