SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
bigdecimal                       Ruby


 The future of the bigdecimal
library and the number system
           of Ruby
mrkn, Kenta Murata (Genetic Lab Co., Ltd)
twitter:
Skype:
Sapporo is a beautiful
provincial city of
Japan.



                     Photo by enggul
from Sapporo,
with Love for Ruby



               Photo by darashi
kosenconf
-­010hokkaido
e rst edition
still in Junkudo.
Sapporo            Kaigi 03
                      03
          MIX
           1 3   1 5
bigdecimal
    Ruby

 The future of the bigdecimal
library and the number system
           of Ruby

mrkn, Kenta Murata (Genetic Lab Co., Ltd)
The bigdecimal library


✓ BigDecimal class

✓ BigMath module
BigDecimal class

✓ require ‘bigdecimal’
✓
    Multiprecision oating point numbers

✓ 10n
    10n-adic representation (modi ed BCD)
BigMath module

✓ BigDecimal      Math
  The Math module for BigDecimals
✓ For examples:
 ✓ Math::PI → BigMath.PI(n)
 ✓ Math.cos(x) → BigMath.cos(x, n)
Problems
✓
    Behavior modes maintained by global variable

✓
    Precision handlings

✓
    Instance generation

✓
    Calculation speed
Modes of BigDecimal
✓ BigDecimal
    Controlling the behaviors of the system of
    BigDecimal class

✓
    Exception handling mode

✓       (         )
    Rounding mode
Exception handling mode

✓
 ✓ In nity
 ✓ NaN
 ✓ Under ow
 ✓ Over ow
 ✓ Division by zero
Rounding modes
✓     Round up

✓     Round down (toward zero)   ←IEEE754

✓     Round half up

✓     Round half down

✓     Banker’s rounding          ←IEEE754

✓     Floor (toward +∞)          ←IEEE754

✓     Ceiling (toward –∞)        ←IEEE754
BigDecimal.mode

✓                 /
    The class method for getting or setting modes

✓
    Maintained per-process

✓
    That is a global variable
Global modes
✓
    Thread unsafe

✓                          2


    Cannot simultaneously start two threads which use
    different modes

✓
    Fiber unsafe
Which BD.mode(BD::EXCEPTION_NAN) is?


BD = BigDecimal

th = Thread.start {
  BD.mode(BD::EXCEPTION_NAN, true)
  ...(A)...
}

BD.mode(BD::EXCEPTION_NAN, false)
...(B)...
th.join
Which BD.mode(BD::EXCEPTION_NAN) is?


BD = BigDecimal

th = Thread.start {
  BD.mode(BD::EXCEPTION_NAN, true)
  ...(A)...
}

BD.mode(BD::EXCEPTION_NAN, false)
...(B)...
th.join

                         It is inde nite X(
Fiber unsafe

BD = BigDecimal
fa = Fiber.new {
  BD.mode(BD::ROUND_MODE, BD::ROUND_UP)
}
Fiber.new {
  BD.mode(BD::ROUND_MODE, BD::ROUND_DOWN)
  fa.resume
  BD.mode(BD::ROUND_MODE) #=> BD::ROUND_UP
}.resume
Modes in thread-local storages

✓ Introduced at r29099 (3 days ago)
✓
    Modes are maintained per-thread

✓
    Threads are initialized with default modes

✓
    Fiber safe
Mode conserving block

✓
    It makes temporary-mode-change easy
✓ BigDecimal.save_exception_mode { ... }
✓ BigDecimal.save_rounding_mode { ... }
✓ Introduced at r29127 (yesterday)
 ✓
Effective digits
✓
    The number of effective digits

✓     :        3   (three digits are effective)
    3.141592653589792...×100
              ↓
    0.314 1592653589792...×101


✓
BigDecimal#precs
✓ prec[1]
    The allocated length of the digit array

✓ prec[2]
    The used length of the digit array

✓
    Not the number of effective digits

✓
    Do you use them?
BigDecimals don’t know their own effective digits



✓ (       )
    We must maintain (multiple) the number of effective digits

✓       Float
    As well as Floats

✓
    It is too much convenient.
    Should be maintained automatically.
Collaborate with Floats

✓            Float
    Force converted into Floats

✓          Float::DIG
    The number of digits is forced to Float::DIG

✓
    It is dangerous, don’t mix them!
Code examples

### (1) ###
BigDecimal("3602879701896397.1") / 36028797018963968
#=> #<BigDecimal:10086d8e0,'0.1000000000 0000000555
1115123125 782702E0',36(54)>         Float::DIG

### (2) ###
BigDecimal("3602879701896397.1") / 36028797018963968.0
#=> 1.0                                             ↑
Instance generation


✓
    Generate from Strings

✓
    Cannot generate from others X(
That is...

a   =   BigDecimal(“3.141592653589”)     #   OK
b   =   BigDecimal(42)                   #   NG
c   =   BigDecimal(Rational(355, 113))   #   NG
d   =   BigDecimal(3.141592653589)       #   NG
That is...

a   =   BigDecimal(“3.141592653589”)     #   OK
b   =   BigDecimal(42)                   #   NG
c   =   BigDecimal(Rational(355, 113))   #   NG
d   =   BigDecimal(3.141592653589)       #   NG

e = BigDecimal(a)                        # NG!!
Float is difficult

✓ Float::RADIX != 10
✓
    Cannot convert exactly due to different radix

✓
    Explicitly specifying the number of effective digits
Calculation speeds

✓
    Implemented only schoolbook multiplication

✓
    Implemented only schoolbook division

✓
    Can get more high speed
e.g.) Karatsuba method

a = a0 × 10n + a1
b = b0 × 10n + b1
c = ab
   = (a0 × 10n + a1)(b0 × 10n + b1)
   = a0b0 × 102n + (a0b1 + a1b0) × 10n + a1b1
   = a0b0 × 102n + [a0b0 + (a0 – a1)(b1 – b0) + a1b1] × 10n + a1b1
Other algorithms

✓ Toom-Cook method
✓ Schönhage-Strassen method
✓ Fürer method
✓ Neuton method (for reciprocal)
Number System of Ruby
        (Float)
     (BigDecimal)

       Integer

       Rational

         N/A

      Complex
Number System of Ruby
        (Float)
     (BigDecimal)

       Integer

       Rational

         N/A

      Complex
Computable Real

✓
    Represents irrational numbers as algorithms
    which generates them

✓
    Decimal representations should be generated
    only if needed
e.g.)   e–iπ   == –1

✓ Present:
  CMath.exp(–Math::PI.i)
  #=> (–1.0–1.2246467991473532e–16i)
✓ Ideal:
  Math.exp(–Math::PI.i)
  #=> –1
Summary

✓ BigDecimal
    BigDecimal has some problems

✓
    Some of these has been xed recently

✓
    We need a class for computable real
Sapporo            Kaigi 03
                      03
          MIX
           1 3   1 5
e rst edition
still in Junkudo.
Rubykaigi2010mrkn bigdecimal

Contenu connexe

Similaire à Rubykaigi2010mrkn bigdecimal

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabVidhyaSenthil
 
C Programming Interview Questions
C Programming Interview QuestionsC Programming Interview Questions
C Programming Interview QuestionsGradeup
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen TatarynovFwdays
 
Linear regression
Linear regressionLinear regression
Linear regressionansrivas21
 
Fosdem2017 Scientific computing on Jruby
Fosdem2017  Scientific computing on JrubyFosdem2017  Scientific computing on Jruby
Fosdem2017 Scientific computing on JrubyPrasun Anand
 
A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...
A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...
A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...Spark Summit
 
[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R台灣資料科學年會
 
PyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at ScalePyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at ScaleGoDataDriven
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Spark Summit
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Daniel Lemire
 
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)Daniel Lemire
 
Faster computation with matlab
Faster computation with matlabFaster computation with matlab
Faster computation with matlabMuhammad Alli
 
#GDC15 Code Clinic
#GDC15 Code Clinic#GDC15 Code Clinic
#GDC15 Code ClinicMike Acton
 

Similaire à Rubykaigi2010mrkn bigdecimal (20)

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
C Programming Interview Questions
C Programming Interview QuestionsC Programming Interview Questions
C Programming Interview Questions
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Fosdem2017 Scientific computing on Jruby
Fosdem2017  Scientific computing on JrubyFosdem2017  Scientific computing on Jruby
Fosdem2017 Scientific computing on Jruby
 
Xgboost
XgboostXgboost
Xgboost
 
Matlab programming
Matlab programmingMatlab programming
Matlab programming
 
A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...
A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...
A Scalable Hierarchical Clustering Algorithm Using Spark: Spark Summit East t...
 
[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R[系列活動] Data exploration with modern R
[系列活動] Data exploration with modern R
 
RCIM 2008 - Modello Generale
RCIM 2008 - Modello GeneraleRCIM 2008 - Modello Generale
RCIM 2008 - Modello Generale
 
PyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at ScalePyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at Scale
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)
 
Word2vec and Friends
Word2vec and FriendsWord2vec and Friends
Word2vec and Friends
 
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
 
Faster computation with matlab
Faster computation with matlabFaster computation with matlab
Faster computation with matlab
 
#GDC15 Code Clinic
#GDC15 Code Clinic#GDC15 Code Clinic
#GDC15 Code Clinic
 
Eye deep
Eye deepEye deep
Eye deep
 
Matlab Workshop Presentation
Matlab Workshop PresentationMatlab Workshop Presentation
Matlab Workshop Presentation
 

Plus de Kenta Murata

Introduction to ATDD with Cucumber and RSpec
Introduction to ATDD with Cucumber and RSpecIntroduction to ATDD with Cucumber and RSpec
Introduction to ATDD with Cucumber and RSpecKenta Murata
 
The world without the literal notation for floating-point numbers
The world without the literal notation for floating-point numbersThe world without the literal notation for floating-point numbers
The world without the literal notation for floating-point numbersKenta Murata
 
The world without float literal
The world without float literalThe world without float literal
The world without float literalKenta Murata
 
Ruby 1.9.3 の新機能と変更点
Ruby 1.9.3 の新機能と変更点Ruby 1.9.3 の新機能と変更点
Ruby 1.9.3 の新機能と変更点Kenta Murata
 
関数型プログラミングの世界
関数型プログラミングの世界関数型プログラミングの世界
関数型プログラミングの世界Kenta Murata
 
Let's begin Behavior Driven Development using RSpec
Let's begin Behavior Driven Development using RSpecLet's begin Behavior Driven Development using RSpec
Let's begin Behavior Driven Development using RSpecKenta Murata
 
Rubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていることRubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていることKenta Murata
 
Ruby の懸案事項
Ruby の懸案事項Ruby の懸案事項
Ruby の懸案事項Kenta Murata
 
5分弱で分かる量子ビット
5分弱で分かる量子ビット5分弱で分かる量子ビット
5分弱で分かる量子ビットKenta Murata
 
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)Kenta Murata
 
校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your school校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your schoolKenta Murata
 
Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案Kenta Murata
 
Measure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリMeasure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリKenta Murata
 
情報学特論#02
情報学特論#02情報学特論#02
情報学特論#02Kenta Murata
 
情報学特論#01
情報学特論#01情報学特論#01
情報学特論#01Kenta Murata
 
北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせ北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせKenta Murata
 
Ruby 拡張モジュール入門
Ruby 拡張モジュール入門Ruby 拡張モジュール入門
Ruby 拡張モジュール入門Kenta Murata
 

Plus de Kenta Murata (18)

Float is Legacy
Float is LegacyFloat is Legacy
Float is Legacy
 
Introduction to ATDD with Cucumber and RSpec
Introduction to ATDD with Cucumber and RSpecIntroduction to ATDD with Cucumber and RSpec
Introduction to ATDD with Cucumber and RSpec
 
The world without the literal notation for floating-point numbers
The world without the literal notation for floating-point numbersThe world without the literal notation for floating-point numbers
The world without the literal notation for floating-point numbers
 
The world without float literal
The world without float literalThe world without float literal
The world without float literal
 
Ruby 1.9.3 の新機能と変更点
Ruby 1.9.3 の新機能と変更点Ruby 1.9.3 の新機能と変更点
Ruby 1.9.3 の新機能と変更点
 
関数型プログラミングの世界
関数型プログラミングの世界関数型プログラミングの世界
関数型プログラミングの世界
 
Let's begin Behavior Driven Development using RSpec
Let's begin Behavior Driven Development using RSpecLet's begin Behavior Driven Development using RSpec
Let's begin Behavior Driven Development using RSpec
 
Rubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていることRubyをたのしくするために私が考えていること
Rubyをたのしくするために私が考えていること
 
Ruby の懸案事項
Ruby の懸案事項Ruby の懸案事項
Ruby の懸案事項
 
5分弱で分かる量子ビット
5分弱で分かる量子ビット5分弱で分かる量子ビット
5分弱で分かる量子ビット
 
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
Ruby における絵文字エンコーディング間の相互変換ダイアグラム (案)
 
校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your school校内勉強会のススメ An encouragement to hold workshops In your school
校内勉強会のススメ An encouragement to hold workshops In your school
 
Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案Ruby の標準乱数生成器とその改善案
Ruby の標準乱数生成器とその改善案
 
Measure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリMeasure 単位付き数値ライブラリ
Measure 単位付き数値ライブラリ
 
情報学特論#02
情報学特論#02情報学特論#02
情報学特論#02
 
情報学特論#01
情報学特論#01情報学特論#01
情報学特論#01
 
北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせ北海道関数型言語勉強会@札幌#2のお知らせ
北海道関数型言語勉強会@札幌#2のお知らせ
 
Ruby 拡張モジュール入門
Ruby 拡張モジュール入門Ruby 拡張モジュール入門
Ruby 拡張モジュール入門
 

Rubykaigi2010mrkn bigdecimal

  • 1. bigdecimal Ruby The future of the bigdecimal library and the number system of Ruby mrkn, Kenta Murata (Genetic Lab Co., Ltd)
  • 3. Sapporo is a beautiful provincial city of Japan. Photo by enggul
  • 4. from Sapporo, with Love for Ruby Photo by darashi
  • 5.
  • 7.
  • 8.
  • 10.
  • 11.
  • 12.
  • 13. Sapporo Kaigi 03 03 MIX 1 3 1 5
  • 14.
  • 15. bigdecimal Ruby The future of the bigdecimal library and the number system of Ruby mrkn, Kenta Murata (Genetic Lab Co., Ltd)
  • 16. The bigdecimal library ✓ BigDecimal class ✓ BigMath module
  • 17. BigDecimal class ✓ require ‘bigdecimal’ ✓ Multiprecision oating point numbers ✓ 10n 10n-adic representation (modi ed BCD)
  • 18. BigMath module ✓ BigDecimal Math The Math module for BigDecimals ✓ For examples: ✓ Math::PI → BigMath.PI(n) ✓ Math.cos(x) → BigMath.cos(x, n)
  • 19. Problems ✓ Behavior modes maintained by global variable ✓ Precision handlings ✓ Instance generation ✓ Calculation speed
  • 20. Modes of BigDecimal ✓ BigDecimal Controlling the behaviors of the system of BigDecimal class ✓ Exception handling mode ✓ ( ) Rounding mode
  • 21. Exception handling mode ✓ ✓ In nity ✓ NaN ✓ Under ow ✓ Over ow ✓ Division by zero
  • 22. Rounding modes ✓ Round up ✓ Round down (toward zero) ←IEEE754 ✓ Round half up ✓ Round half down ✓ Banker’s rounding ←IEEE754 ✓ Floor (toward +∞) ←IEEE754 ✓ Ceiling (toward –∞) ←IEEE754
  • 23. BigDecimal.mode ✓ / The class method for getting or setting modes ✓ Maintained per-process ✓ That is a global variable
  • 24. Global modes ✓ Thread unsafe ✓ 2 Cannot simultaneously start two threads which use different modes ✓ Fiber unsafe
  • 25. Which BD.mode(BD::EXCEPTION_NAN) is? BD = BigDecimal th = Thread.start { BD.mode(BD::EXCEPTION_NAN, true) ...(A)... } BD.mode(BD::EXCEPTION_NAN, false) ...(B)... th.join
  • 26. Which BD.mode(BD::EXCEPTION_NAN) is? BD = BigDecimal th = Thread.start { BD.mode(BD::EXCEPTION_NAN, true) ...(A)... } BD.mode(BD::EXCEPTION_NAN, false) ...(B)... th.join It is inde nite X(
  • 27. Fiber unsafe BD = BigDecimal fa = Fiber.new { BD.mode(BD::ROUND_MODE, BD::ROUND_UP) } Fiber.new { BD.mode(BD::ROUND_MODE, BD::ROUND_DOWN) fa.resume BD.mode(BD::ROUND_MODE) #=> BD::ROUND_UP }.resume
  • 28. Modes in thread-local storages ✓ Introduced at r29099 (3 days ago) ✓ Modes are maintained per-thread ✓ Threads are initialized with default modes ✓ Fiber safe
  • 29. Mode conserving block ✓ It makes temporary-mode-change easy ✓ BigDecimal.save_exception_mode { ... } ✓ BigDecimal.save_rounding_mode { ... } ✓ Introduced at r29127 (yesterday) ✓
  • 30. Effective digits ✓ The number of effective digits ✓ : 3 (three digits are effective) 3.141592653589792...×100 ↓ 0.314 1592653589792...×101 ✓
  • 31. BigDecimal#precs ✓ prec[1] The allocated length of the digit array ✓ prec[2] The used length of the digit array ✓ Not the number of effective digits ✓ Do you use them?
  • 32. BigDecimals don’t know their own effective digits ✓ ( ) We must maintain (multiple) the number of effective digits ✓ Float As well as Floats ✓ It is too much convenient. Should be maintained automatically.
  • 33. Collaborate with Floats ✓ Float Force converted into Floats ✓ Float::DIG The number of digits is forced to Float::DIG ✓ It is dangerous, don’t mix them!
  • 34. Code examples ### (1) ### BigDecimal("3602879701896397.1") / 36028797018963968 #=> #<BigDecimal:10086d8e0,'0.1000000000 0000000555 1115123125 782702E0',36(54)> Float::DIG ### (2) ### BigDecimal("3602879701896397.1") / 36028797018963968.0 #=> 1.0 ↑
  • 35. Instance generation ✓ Generate from Strings ✓ Cannot generate from others X(
  • 36. That is... a = BigDecimal(“3.141592653589”) # OK b = BigDecimal(42) # NG c = BigDecimal(Rational(355, 113)) # NG d = BigDecimal(3.141592653589) # NG
  • 37. That is... a = BigDecimal(“3.141592653589”) # OK b = BigDecimal(42) # NG c = BigDecimal(Rational(355, 113)) # NG d = BigDecimal(3.141592653589) # NG e = BigDecimal(a) # NG!!
  • 38. Float is difficult ✓ Float::RADIX != 10 ✓ Cannot convert exactly due to different radix ✓ Explicitly specifying the number of effective digits
  • 39. Calculation speeds ✓ Implemented only schoolbook multiplication ✓ Implemented only schoolbook division ✓ Can get more high speed
  • 40. e.g.) Karatsuba method a = a0 × 10n + a1 b = b0 × 10n + b1 c = ab = (a0 × 10n + a1)(b0 × 10n + b1) = a0b0 × 102n + (a0b1 + a1b0) × 10n + a1b1 = a0b0 × 102n + [a0b0 + (a0 – a1)(b1 – b0) + a1b1] × 10n + a1b1
  • 41. Other algorithms ✓ Toom-Cook method ✓ Schönhage-Strassen method ✓ Fürer method ✓ Neuton method (for reciprocal)
  • 42.
  • 43. Number System of Ruby (Float) (BigDecimal) Integer Rational N/A Complex
  • 44. Number System of Ruby (Float) (BigDecimal) Integer Rational N/A Complex
  • 45. Computable Real ✓ Represents irrational numbers as algorithms which generates them ✓ Decimal representations should be generated only if needed
  • 46. e.g.) e–iπ == –1 ✓ Present: CMath.exp(–Math::PI.i) #=> (–1.0–1.2246467991473532e–16i) ✓ Ideal: Math.exp(–Math::PI.i) #=> –1
  • 47. Summary ✓ BigDecimal BigDecimal has some problems ✓ Some of these has been xed recently ✓ We need a class for computable real
  • 48. Sapporo Kaigi 03 03 MIX 1 3 1 5
  • 49.
  • 50.
  • 51. e rst edition still in Junkudo.