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!
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