Project

General

Profile

Actions

Bug #17630

closed

'+' doesn't work correctly for some floats (x.07 + y.4 will give z.46999999999997 instead of z.47)

Added by zGalili (Ziv Galili) about 2 months ago. Updated about 2 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:102502]

Description

1.02 + 1.4 will give 2.42 as expected

but not for all cases.

examples for wrong answers:

1.07 + 1.4
-> 2.4699999999999998
255.07 + 5.4
-> 260.46999999999997
480.07 + 5.4
-> 485.46999999999997

other numbers works correctly:

255.06 + 5.5
-> 260.56
2.07 + 222222.4
-> 222224.47

seems like the problem is with x.07 + y.4 but only for some results.

Updated by ufuk (Ufuk Kayserilioglu) about 2 months ago

You might also want to take a look at this: https://0.30000000000000004.com/

Updated by mame (Yusuke Endoh) about 2 months ago

  • Status changed from Open to Rejected

As they say, this is by design. Closing.

Actions

Also available in: Atom PDF