From: Robert Klemme Date: 2010-04-29T05:20:06+09:00 Subject: Re: flt gem for arbitrary precision On 04/28/2010 11:31 AM, Giampiero Zanchi wrote: > ciao a tutti (hi to hall) > > I just discoverd a gem to have arbitrary precision numbers and want to > share with the forum. > > Install the gem with > > gem install flt > > an example script follows; it computes the square root of 2 > > require 'flt' > include Flt > > DecNum.context.precision = 200 > > p DecNum(2).sqrt > > produces: > > DecNum('1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727350138462309122970249248360558507372126441214970999358314132226659275055927557999505011527820605715') > > documentation here > http://flt.rubyforge.org/ What's the difference (precision? performance?) vs. doing irb(main):001:0> require 'bigdecimal' => true irb(main):002:0> BigDecimal("2").sqrt(200).to_s => "0.1414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641572735013846230912297024924836055850737212644121497099935831413222665927505592755799950501152782060571470109559971605970125E1" irb(main):003:0> BigDecimal("2").sqrt(200) => # irb(main):004:0> ? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/