Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Pentium math???

by desertrat (Acolyte)
on Apr 25, 2012 at 19:14 UTC ( #967148=perlquestion: print w/ replies, xml ) Need Help??
desertrat has asked for the wisdom of the Perl Monks concerning the following question:

Consider the simple code:

#!/usr/bin/perl use strict; use warnings; my $i = 2456043.499992; my $j = int($i); my $k = $i-$j; print "$i - $j == $k\n"; exit;

Which gives me the nonsensical results:

dbdev2:~ johnson$ perl test

2456043.499992 - 2456043 == 0.499991999939084

Huh?

Comment on Pentium math???
Download Code
Replies are listed 'Best First'.
Re: Pentium math???
by toolic (Bishop) on Apr 25, 2012 at 19:19 UTC
Re: Pentium math???
by davido (Archbishop) on Apr 25, 2012 at 22:19 UTC
Re: Pentium math???
by BillKSmith (Deacon) on Apr 25, 2012 at 21:10 UTC
Re: Pentium math???
by Anonymous Monk on Apr 26, 2012 at 04:30 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://967148]
Approved by toolic
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2015-07-29 14:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls