in reply to subtraction issue
Disproven:
#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; my $v_amount = -683.12; my $plbamt = -683.12; my $finalamount = $v_amount - ($plbamt); # Why have brackets here, OP? is ($finalamount, 0, 'Nothing to see here');
can anyone tell me why this is?
Yes, it is because at least one of $v_amount or $plbamt does not have the value which you think it has. See the links the other monks have given you regarding imprecision of floating point numbers in computing.
|
|---|