Upcoming SlideShare
×

# The world without the literal notation for floating-point numbers

1,873 views
1,761 views

Published on

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

Published in: Technology, Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Views
Total views
1,873
On SlideShare
0
From Embeds
0
Number of Embeds
151
Actions
Shares
0
2
0
Likes
0
Embeds 0
No embeds

No notes for slide

### The world without the literal notation for floating-point numbers

1. 1. The world without the literal notation for ﬂoating-point numbers , Kenta Murata GeneticLab Co., Ltd.Tuesday, July 19, 2011 1
2. 2. CRuby Committer (BigDecimal) Ruby Sapporo Kosen Confhttp://www.flickr.com/photos/koichiroo/5244581973/Tuesday, July 19, 2011 2
3. 3. Tuesday, 12010 3 July 19, 2011 3
4. 4. RubyKaigi n !!Tuesday, 12010 3 July 19, 2011 4
5. 5. Ruby 04 Sapporo RubyKaigi 04 Summer 2012Tuesday, 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 difﬁcult.Tuesday, July 19, 2011 9
10. 10. Reading difﬁcultyTuesday, 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 difﬁcultyTuesday, 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 differenceTuesday, July 19, 2011 14
15. 15. Human: Decimal Internal: BinaryTuesday, July 19, 2011 15
16. 16. Concept differenceTuesday, 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 troublesomeTuesday, July 19, 2011 19
20. 20. There is a solutionTuesday, July 19, 2011 20
21. 21. Why not use Rational.Tuesday, July 19, 2011 21
22. 22. It is difﬁcult, too.Tuesday, July 19, 2011 22
23. 23. Ruby doesn’t have any literal notations for RationalTuesday, 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 10nTuesday, July 19, 2011 30
31. 31. Float isn’t as so fast as you thinkTuesday, July 19, 2011 31
32. 32. If you need fast Float calculationTuesday, July 19, 2011 32
33. 33. Write it in C as extension libraryTuesday, July 19, 2011 33
34. 34. If you need to calculate with arrays of FloatTuesday, July 19, 2011 34
35. 35. Use NArrayTuesday, July 19, 2011 35
36. 36. Rational may be what you wantTuesday, July 19, 2011 36
37. 37. This talk’s background, demonstrations, and more detail descriptionsTuesday, July 19, 2011 37
38. 38. Tuesday, July 19, 2011 38