[Israel.pm] floating point curiosity

Levenglick Dov-RM07994 Dov at freescale.com
Wed Jan 4 04:32:11 PST 2006


Hi,
Can someone please explain what is happening here?

#!/usr/local/bin/perl5.6.1
$float1 = 16.05;
$float2 = 32.05;
$float3 = 512.05;
print $float1, " ", $float1*1000, " ", int ($float1*1000), "\n";
print $float2, " ", $float2*1000, " ", int ($float2*1000), "\n";
print $float3, " ", $float3*1000, " ", int ($float3*1000), "\n";

Produces:
16.05 16050 16050
32.05 32050 32049
512.05 512050 512049

The question has to last printed value.

 
Best Regards,
Dov Levenglick
DSP SoC System and Applications Engineer,
Network and Computing Systems Group
Freescale Semiconductor Israel
Tel. +972-9-952-2804
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
 





More information about the Perl mailing list