Phil Tomson wrote: > Constuction with Strings is not currently supported, but that's a > thought. Practically speaking, I'm not sure how big of a problem this > is, I doubt I'd really need to have a FixedPt number with more > precision than Ruby has. > > I did some experimenting in irb to find out where the cutoff is: > > irb(main):027:0> x = 9.0000000000001 > => 9.0000000000001 > irb(main):028:0> x = 9.00000000000001 > => 9.00000000000001 > irb(main):029:0> x = 9.000000000000001 > => 9.0 > > It happens at 15 digits to the right of the decimal point. (When you > go the other way by increasing the size of the number you automatically > convert to a Bignum - however we don't have a 'Smallnum' equivilent when the > numbers get very small.) BigDecimal would work, but does AFAIK not automatically take care of the precision that would be needed to avoid data loss. Keeping numbers around as Rational and converting to a BigDecimal on output might work in that cases. > That would be about 50 fractional bits in a > binary fixed point number - practically speaking, you usually (where > 'usually' probably covers 99.999% of the cases ) don't need that kind of > precision in a hardware implementation of an algorithm. Ah, I'm not sure how frequently such accurate numbers are used (I'm not experienced at hardware design), but it might still be worth considering. After all 1.1 will not be accurately presented (the first error occurs at the 15th digit) either. > [...] > > I implemented a model of a Support Vector Machine (kind of like a > Perceptron, a type of artificial neuron) using FixedPt and an exp(-x) > lookup table and came up with the following results: > > 1) I needed 9 fractional bits at a minimum. > 2) The value of x for which exp(-x) = 0.0 was -12.25. > 3) The number of entries in the exp(-x) lookup table was 128 (7 bits of > address) which was surprisingly small. Thank you for the detailed description of the process where this library would be involved. It was very interesting for me -- always nice to see where Ruby can be used in the real world where you might not have expected it to be at first. Perhaps this is an interesting enough use case for it to be added to the RealWorldRuby page of the rubygarden.org Wiki? If you can name the company you are doing this for then even better. :) Anyway, I think you are likely right in that this will rarely be much of a problem -- but having the possibility in the next release (there will be one anyway, won't there? ;)) might still be a good thing -- even if just getting users in the habit of being careful with Floats. Yours will probably know anyway, but allowing for such a style consistently through all libraries should keep confusion low.