4 ms·
That is called 'fixed point', and it is useful for some applications. What makes floating point interesting is that it can represent values with very different
by moonchild 4y ago
That is called 'fixed point', and it is useful for some applications. What makes floating point interesting is that it can represent values with very different magnitudes; your 64-bit fixed point number can't represent any number greater than 1, for instance. Whereas a 32-bit float can represent numbers with magnitudes between ~2^-127 and ~2^127.
- psychphysic 4y agoMaybe Cosine could be fixed and converter to float before use. Using identities to calculate Sine and Tangent functions.
- bigbillheck 4y agoSeems like a lot of effort for no actual gain.
- psychphysic 4y agoJust an option if magnitude is an issue. You only needs 0-1 plus a sign bit. Fixed to float is easy enough. It'd let you use a fixed point implementation for 0 - pi/2 benefiting from smaller look up table and simpler implementation.
- Someone 4y ago> It'd let you use a fixed point implementation for 0 - pi/2 benefiting from smaller look up table Why would that table be smaller if you use 2^64 values in that range instead of the fewer than 2^55 doubles in that range? > and simpler implementation. Why would it be simpler? With doubles, the hardware will do scaling for you. With fixed point, you need a helper function or macro to do multiplications, and those have to use an intermediate result with more than 64 bits (in this special case, some shortcuts are possible, but those won’t make the implementation simpler).
- psychphysic 4y agoOne or both of us have lost the thread here. There was an exchange about using fixed point (which apparently is being used according to other comments for easier correctness verification, speed and simplicity). Someone pointed out that float gives you a wider range of values. But those values are not needed for cosine which has a range of 0-1 in the interval 0 to pi/2.
- dahart 4y ago> But those values are not needed for cosine which has a range of 0-1 in the interval 0 to pi/2 Ah not quite true though; the “range” is also referring to the exponent range of representable numbers, so don’t forget the small numbers near 0. You can get much smaller numbers with much higher precision out of a single-precision float than a fixed-point 64 bit [0,1] number.
- psychphysic 4y agoAh makes sense. I imagine depending one how you intend to use the numbers you need that precision at the steeper parts too.