5 ms·
Just 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
by psychphysic 4y ago
Just 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.