0002 Float_precision

Float precision is not infinite. Depending on your use case, you need to be very careful.

« It’s 1$ for this delicious chocolate. »

« Perfect, I have 10 dimes. »

« Sorry, you don’t have enough! »

0002-float_precision_1.png

Ruby can address this problem thanks to Rational, which it handles natively.

« Ok, now you have enough. »

0002-float_precision_2.png

Link to Ruby documentation for Rational