On Wed, 7 Dec 2005 [EMAIL PROTECTED] wrote:
> Hi,
>
> I don't know why the result of my calculation doesn't make sense!
>
>
> foreach('0.43','-0.12','-0.08','-0.17','-0.06') {
> $value = $value + ($_);
> }
> print $value . "<br>";
>
> Value = -2.77555756156289e-17
> Should be 0.00
What is the difference between -2.77555756156289e-17 and 0.00?
It's all to do with the way numbers are represented in computers.
Do a "perldoc -f sprintf" and have a read.
Owen
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>