Successfully reported this slideshow.
Your SlideShare is downloading. ×

The world without the literal notation for floating-point numbers

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 38 Ad

The world without the literal notation for floating-point numbers

Download to read offline

We need the decimal-point literal notation for Rational instead of Float because Float is legacy.

We need the decimal-point literal notation for Rational instead of Float because Float is legacy.

Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

The world without the literal notation for floating-point numbers

  1. 1. The world without the literal notation for floating-point numbers , Kenta Murata GeneticLab Co., Ltd. Tuesday, July 19, 2011 1
  2. 2. CRuby Committer (BigDecimal) Ruby Sapporo Kosen Conf http://www.flickr.com/photos/koichiroo/5244581973/ Tuesday, July 19, 2011 2
  3. 3. Tuesday, 1 2010 3 July 19, 2011 3
  4. 4. RubyKaigi n !! Tuesday, 1 2010 3 July 19, 2011 4
  5. 5. Ruby 04 Sapporo RubyKaigi 04 Summer 2012 Tuesday, July 19, 2011 5
  6. 6. I have some question. Tuesday, July 19, 2011 6
  7. 7. Do you use Float values? Tuesday, July 19, 2011 7
  8. 8. Do you understand Float well? Tuesday, July 19, 2011 8
  9. 9. Float is too difficult. Tuesday, July 19, 2011 9
  10. 10. Reading difficulty Tuesday, July 19, 2011 10
  11. 11. ruby-1.9.2-p290 :001 > 76287755398823936.0 => 76287755398823940.0 ruby-1.9.2-p290 :002 > Tuesday, July 19, 2011 11
  12. 12. Comparing difficulty Tuesday, July 19, 2011 12
  13. 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
  14. 14. Representation difference Tuesday, July 19, 2011 14
  15. 15. Human: Decimal Internal: Binary Tuesday, July 19, 2011 15
  16. 16. Concept difference Tuesday, July 19, 2011 16
  17. 17. We think Float is a number. Tuesday, July 19, 2011 17
  18. 18. It is real that Float is a range. Tuesday, July 19, 2011 18
  19. 19. They’re troublesome Tuesday, July 19, 2011 19
  20. 20. There is a solution Tuesday, July 19, 2011 20
  21. 21. Why not use Rational. Tuesday, July 19, 2011 21
  22. 22. It is difficult, too. Tuesday, July 19, 2011 22
  23. 23. Ruby doesn’t have any literal notations for Rational Tuesday, July 19, 2011 23
  24. 24. Does a fractional notation solve the problems? Tuesday, July 19, 2011 24
  25. 25. No! Tuesday, July 19, 2011 25
  26. 26. We naturally use decimal point notation. Tuesday, July 19, 2011 26
  27. 27. We need a decimal- point notation for representing a Rational. Tuesday, July 19, 2011 27
  28. 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. 29. Do you worry about Rational is slow? Tuesday, July 19, 2011 29
  30. 30. We can optimize for denominators of 10n Tuesday, July 19, 2011 30
  31. 31. Float isn’t as so fast as you think Tuesday, July 19, 2011 31
  32. 32. If you need fast Float calculation Tuesday, July 19, 2011 32
  33. 33. Write it in C as extension library Tuesday, July 19, 2011 33
  34. 34. If you need to calculate with arrays of Float Tuesday, July 19, 2011 34
  35. 35. Use NArray Tuesday, July 19, 2011 35
  36. 36. Rational may be what you want Tuesday, July 19, 2011 36
  37. 37. This talk’s background, demonstrations, and more detail descriptions Tuesday, July 19, 2011 37
  38. 38. Tuesday, July 19, 2011 38

×