0

I wrote this in rails console

(3352.3744333333334==3352.3744333333335) #true

and result was true

Notes:

I'm using ruby 2.4.0 and rails 5.0.1

enter image description here

  • 1
    For exact math use [*Rational*](http://ruby-doc.org/core-2.5.3/Rational.html), [*BigDecimal*](http://ruby-doc.org/stdlib-2.5.3/libdoc/bigdecimal/rdoc/BigDecimal.html) or [*Integer*](http://ruby-doc.org/core-2.5.3/Integer.html). For example when working with money, use integers and save the amount of cents instead of dollars (eg. 10010 cent equals 100.10 dollar). – 3limin4t0r Dec 17 '18 at 17:57

1 Answers1

-1

I’m not an expert in ruby but my best answer is that the code is printing out all of the numbers but only comparing like the first 10 digits meaning 3352.374433 to 3352.374433 and it’s not going further than that. This would be the most logical explanation In my mind