From: duerst@... Date: 2020-05-10T00:34:39+00:00 Subject: [ruby-core:98245] [Ruby master Bug#16843] A bug with floating point multiplication Issue #16843 has been updated by duerst (Martin D�rst). Just as an add-on: Go has similar effects to those reported here for Ruby, see e.g. https://stackoverflow.com/questions/33640943/golang-float-arithmetic. @FedorKK, if you can find out *why* e.g. `fmt.Println(0.29 * 100 == 29.0)` prints true in Go, please tell us. ---------------------------------------- Bug #16843: A bug with floating point multiplication https://bugs.ruby-lang.org/issues/16843#change-85486 * Author: FedorKK (Fedor Koshel) * Status: Rejected * 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: