Jump to content

SIMPLE addition


Guest

Recommended Posts

hi-

 

this is ridiculous. i'm not sure if anyone else has seen this before. i have a simple file:

 

<?php echo(0.09 + 0.01 . "\n"); ?>

 

that's it! literally! this returns:

 

0.0:

 

it should be 0.1!!! if i change the numbers:

 

<?php echo(0.09 + 0.02 . "\n"); ?>

 

it returns this:

 

0.11

 

which is correct. i discovered this problem when i was working with long exponentials like this:

 

<?php echo(9.0E-8 + 1E-8 . "\n"); ?>

 

which returned:

 

:.0E-8

 

so, my question is, what is going on? what is this colon? i'm not new to php, i've been using it for almost 8 years. this is the only problem I'm having with it. i'm using ubuntu hardy heron (most recent updates from the repositories). i am not using the server version of it. i am using the client side, php5-cli, 5.2.4-2ubuntu5.2. has anyone else seen this before?!

Link to comment
https://forums.phpfreaks.com/topic/114939-simple-addition/
Share on other sites

really weird! this:

 

<?php

echo(0.9 + 0.1 . "\n");
echo(0.09 + 0.01 . "\n");
echo(0.009 + 0.001 . "\n");
echo(0.0009 + 0.0001 . "\n");
echo(0.00009 + 0.00001 . "\n");
echo(0.000009 + 0.000001 . "\n");
echo(0.0000009 + 0.0000001 . "\n");
echo(0.00000009 + 0.00000001 . "\n");
echo(0.000000009 + 0.000000001 . "\n");
echo(0.0000000009 + 0.0000000001 . "\n");
echo(0.00000000009 + 0.00000000001 . "\n");

?>

 

returns this:

 

1
0.0:
0.01
0.001
0.0001
1.0E-5
:.0E-7
:.0E-8
1.0E-8
1.0E-9
1.0E-10

Link to comment
https://forums.phpfreaks.com/topic/114939-simple-addition/#findComment-591153
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.