lo0ol / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

Summing #76

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a code as on the screenshot
2. Run and set numbers as 3.1 and 3.2 i.e.
3. Get an answer like 6.300000000001

What is the expected output? What do you see instead?
Expected: 6.3. Seen - 6.300000000001

What browser are you using?
Chrome 22.0.1229.64 beta-m
Win7 Pro x64

Please provide any additional information below.
Looks like bug appears only with x.1 numbers

Original issue reported on code.google.com by nixel2...@gmail.com on 25 Sep 2012 at 5:27

Attachments:

GoogleCodeExporter commented 8 years ago
Not only with x.1
When Blockly needs to summ numbers with increment cause of fractional part. 
i.e. 3.7 + 4.4 cause the problem, but 3.3 + 4.4 - not. I hope, I explained it 
clearly.

Original comment by nixel2...@gmail.com on 25 Sep 2012 at 5:31

GoogleCodeExporter commented 8 years ago
Hello,

Welcome to the wonderful world of floating point binary arithmetic.  If you 
execute '3.7 + 4.4' in JavaScript, Python, Dart, or most other computer 
languages, the result is '8.100000000000001'.

For detailed discussion on this error, see:
"What Every Computer Scientist Should Know About Floating-Point Arithmetic"
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

For a more accessible discussion, see:
"Python: Floating Point Arithmetic: Issues and Limitations"
http://docs.python.org/tutorial/floatingpoint.html

You might wish to round the output if this matters.

Original comment by neil.fra...@gmail.com on 25 Sep 2012 at 6:13

GoogleCodeExporter commented 8 years ago
Ah, you are right, i forgot about float point operations. 
Thank you and sorry for disturb.

Original comment by nixel2...@gmail.com on 25 Sep 2012 at 6:26