Module: Flt::BinNum::Trigonometry
- Defined in:
- lib/flt/trigonometry.rb
Instance Method Summary collapse
Instance Method Details
#pi(round_digits = nil) ⇒ Object
729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'lib/flt/trigonometry.rb', line 729 def pi(round_digits=nil) round_digits ||= self.precision nhexd = (round_digits+3)/4 + 1 v = Num[16]::Trigonometry.pi_hex_digits(nhexd) l = v.size v = v.to_i(16) e = (1-l)*4 # add trailing 01 for rounding (there always be some non null digit beyond the rounding point) v <<= 2 v |= 1 e -= 2 num_class.context(self, :precision=>round_digits){+num_class.Num(+1,v,e)} end |