More Related Content
Similar to The world without float literal
Similar to The world without float literal (15)
More from Kenta Murata (12)
The world without float literal
- 1. The world without the
literal notation for
floating-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
- 4. RubyKaigi
n !!
Tuesday, 1
2010 3 July 19, 2011 4
- 5. Ruby 04
Sapporo RubyKaigi 04
Summer 2012
Tuesday, July 19, 2011 5
- 7. Do you use Float
values?
Tuesday, July 19, 2011 7
- 11. ruby-1.9.2-p290 :001 > 76287755398823936.0
=> 76287755398823940.0
ruby-1.9.2-p290 :002 >
Tuesday, July 19, 2011 11
- 13. ruby-1.9.2-p290 :001 > 12.4 * 1.05 == 13.02
=> false
ruby-1.9.2-p290 :002 > 12.4 * 1.05
=> 13.020000000000001
ruby-1.9.2-p290 :003 >
Tuesday, July 19, 2011 13
- 16. Concept
difference
Tuesday, July 19, 2011 16
- 17. We think
Float is a number.
Tuesday, July 19, 2011 17
- 18. It is real that
Float is a range.
Tuesday, July 19, 2011 18
- 27. We need a decimal-
point notation for
representing a Rational.
Tuesday, July 19, 2011 27
- 28. ruby--p290 :001 > 13.02.class
=> Rational
ruby--p290 :001 > 12.4 * 1.05 == 13.02
=> true
ruby-1.9.2-p290 :002 > 12.4 * 1.05
=> 13.02
ruby-1.9.2-p290 :003 > 13.02 / 3
=> (217/50)
Tuesday, July 19, 2011 28
- 29. Do you worry about
Rational is slow?
Tuesday, July 19, 2011 29
- 32. If you need fast Float
calculation
Tuesday, July 19, 2011 32
- 33. Write it in C as
extension library
Tuesday, July 19, 2011 33
- 34. If you need to calculate
with arrays of Float
Tuesday, July 19, 2011 34