Discussion

1.15 * 100 = 149.99999999999999 except in Ruby

All I've tried (Haskell (GHC), Python, Erlang, Clojure, Ruby) except Ruby give 149.99999999999999. What IEEE floating point (double/single precision) standard is causing this :) and why doesn't it happen in Ruby?

  $ ghic
  Prelude> 1.15 * 100
  114.99999999999999

  $ python
  >>> 1.15 * 100
  114.99999999999999

  $ erl
  1> 1.15 * 100.
  114.99999999999999

  $ irb 
  >> 1.15 * 100
  => 115.0
10 points kungfooguru 15 years ago 17 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton