The document discusses the difficulties of using floating point numbers (Floats) in Ruby and proposes using Rational numbers instead. Some key points made include:
- Floats are stored internally as binary which can lead to representation errors, while we think of them as decimal numbers
- Floats actually represent a range of values rather than a single number
- Using Rational would allow keeping numbers as exact fractions, avoiding errors from Float representations
- While Rational may seem slower, optimizations are possible for common denominators and FastMath libraries could be used for Floats if needed
1 of 38
Download to read offline
More Related Content
The world without float literal
1. The world without the
literal notation for
?oating-point numbers
, Kenta Murata
GeneticLab Co., Ltd.
Tuesday, July 19, 2011 1
2. CRuby Committer
(BigDecimal)
Ruby Sapporo
Kosen Conf
http://www.flickr.com/photos/koichiroo/5244581973/
Tuesday, July 19, 2011 2