From: fedorkk@... Date: 2020-05-09T16:50:15+00:00 Subject: [ruby-core:98234] [Ruby master Bug#16843] A bug with floating point multiplication Issue #16843 has been updated by FedorKK (Fedor Koshel). The behaviour is super unpredictable. I mean, the problem with floats is known, but it usually happens with precision values, or huge numbers. In this case, if you try to get an integer from 0.29*100 you'll get 28. Which is strange. If you think, this is just another float discuss, you can close the ticket. But for me the work with simple numbers should be more predictable. ---------------------------------------- Bug #16843: A bug with floating point multiplication https://bugs.ruby-lang.org/issues/16843#change-85472 * Author: FedorKK (Fedor Koshel) * Status: Open * Priority: Normal * ruby -v: 2.6.6, 2.7.1 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- I've reproduced it with both currently stable versions: 2.6.6 and 2.7.1. ``` ruby irb(main):001:0> 0.29 * 100 => 28.999999999999996 irb(main):002:0> 0.29 * 100.0 => 28.999999999999996 irb(main):003:0> 0.28 * 100 => 28.000000000000004 irb(main):004:0> 0.28 * 100.0 => 28.000000000000004 irb(main):005:0> 0.27 * 100.0 => 27.0 irb(main):006:0> 0.27 * 100 => 27.0 $ ruby -v ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux] ``` ``` ruby irb(main):001:0> 0.29 * 100 => 28.999999999999996 irb(main):002:0> 0.29 * 100.0 => 28.999999999999996 irb(main):003:0> 0.28 * 100.0 => 28.000000000000004 irb(main):004:0> 0.28 * 100 => 28.000000000000004 irb(main):005:0> 0.27 * 100 => 27.0 irb(main):006:0> 0.27 * 100.0 => 27.0 $ ruby -v ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux] ``` -- https://bugs.ruby-lang.org/ Unsubscribe: