Simple Mathematics

Open a python shell. and type like this

>>> 9 *0.000001
output : 9.0000000000000002e-06
>>> 99 *0.000001
output : 9.8999999999999994e-05
>>> 111 *0.000001
output : 0.000111
>>> 999 *0.000001
output : 0.00099899999999999989

See the difference between first, second & third, fourth. First two takes floating notation.

So while  coding in any scripting language take care of this. It  may cause some simple bugs sometimes even critical.

In php we can use number_format() function to get all the outputs in decimal notation.  So there will be no mismatch in formats there by reducing the chance of creating a bug.


One Response to Simple Mathematics

  1. Jithu Gopal says:

    Good going buddy! Keep blogging!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: