From: Axel Friedrich Date: 2012-12-10T23:58:16+09:00 Subject: Re: Binary Fixed-Point in Ruby? (Improved FixedPt?) Unfortunatly, I don't understand how BigDecimal could help with my Binary- Fixed-Point problems. Maybe I should explain in more details: I have _no_ problem with accuracy. I'm developing hardware, which calculates mathematic expressions using "fixed-point binary representations" of values. That is a certain number of bits (say 16) represent a value (say 0.1). The format of the fixed-point representation must "set" right (right number of bits and right place of the virtual binary point), in order to avoid overflow or loss of accuracy. For checking, if I have "set" the format right, I want to simulate it in Ruby. Normaly, Ruby does it's calculations in Integer, or Double or even BigDecimal, but not in BINARY Fixed-Point, so I think I must use a special library for this, for example the existing "FixedPt"-library. But unfortunately, this library is not perfect enough for my purpose. Maybe this explains it better: http://en.wikibooks.org/wiki/Floating_Point/Fixed-Point_Numbers Axel Bartosz DziewoƄski wrote in post #1088523: > There is BigDecimal in the standard library. > > irb(main):011:0> require 'bigdecimal' > => true > irb(main):012:0> BigDecimal > => BigDecimal > irb(main):014:0> BigDecimal.new '123' > => # > > http://www.ruby-doc.org/stdlib-1.9.3/libdoc/bigdecimal/rdoc/index.html > > -- Matma Rex -- Posted via http://www.ruby-forum.com/.