Re: Hi, strange problem on calculation

2005-12-07 Thread Owen Cook

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 . "";
> 
> 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]
 




Hi, strange problem on calculation

2005-12-07 Thread webmaster
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 . "";

Value = -2.77555756156289e-17
Should be 0.00


My Perl Version is:
perl -V
Summary of my perl5 (revision 5 version 8 subversion 4)



Mit freundlichen GrĂ¼ssen
Ihr echtwahr.Webmaster


http://www.echtwahr.de
http://www.echtwahr.com




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]