Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Bug? 1+1 != 2

by bobn (Chaplain)
on Jun 19, 2003 at 06:54 UTC ( [id://267099]=note: print w/replies, xml ) Need Help??


in reply to Bug? 1+1 != 2

I don't get it. It doesn't look like a logic issue, though.

issuing :%s/0\.0/0./g while editing in vi, writing and executing yields:
#!/usr/bin/perl use strict; use warnings; my $base = 0.425; while ( my $line = <DATA>){ chomp $line; my ($z,$c1,$c2,$c3,$c4) = split(/,/,$line); print join("|",$z,$c1,$c2,$c3,$c4),"\n"; my $total = $c1+$c2+$c3; print $c4 == ($total + $base) ? "True\n" : "False $c4 != ".($total+$ +base)."\n"; } __DATA__ 00501,0.000,0.425,0.025,0.875 00544,0.000,0.425,0.025,0.875 06390,0.000,0.425,0.025,0.875
with results:
00501|0.000|0.425|0.025|0.875 True 00544|0.000|0.425|0.025|0.875 True 06390|0.000|0.425|0.025|0.875 True
So making everything 10 times bigger yields expected results. Rounding error?

--Bob Niederman, http://bob-n.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://267099]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found