Since there are two ways of implementing an AP fractional number, one is to emulate the storage and behavior of the double
data type, only with more bytes, and the other is to use an existing integer APA implementation for representing a fractional number as a rational i.e. as a pair of integers, numerator and denominator, which of the two ways are more likely to deliver efficient arithmetic in terms of performance? (Memory usage is really of minor concern.)
I'm aware of the existing C/C++ libraries, some of which offer fractional APA with "floats" and other with rationals (none of them features fixed-point APA, however) and of course I could benchmark a library that relies on "float" implementation against one that makes use of rational implementation, but the results would largely depend on implementation details of those particular libraries I would have to choose randomly from the nearly ten available ones. So it's more theoretical pros and cons of the two approaches that I'm interested in (or three if take into consideration fixed-point APA).
0
, dropping as we get farther away from0
, and catastrophically "sparse" at the remote ends of the range. Do you really need this property? Or did you just use floating-point as a generic term for any fractional number? In other words, why isn't fixed-point arithmetic considered? – Cinderx = y * a / b
. In such cases the post-adjustment for mul and div is not necessary. This is the beauty of fixed point, since in such cases one can easily optimize and just use full efficiency of integer operations. In my applications (computational geometry) perfectly balanced muls/divs are actually encountered more often than non-balanced ones, which is what makes fixed-point especially attractive. – Cinder