4 ms·
You don’t divide a float by 256 by shifting it right eight bits; that would yield complete garbage. You subtract 8 from the exponent, then check if you got an u
by xigoi 5mo ago
You don’t divide a float by 256 by shifting it right eight bits; that would yield complete garbage. You subtract 8 from the exponent, then check if you got an underflow.
- dheera 5mo agoSame point; divide by power of 2 is a fast subtraction operation in float world, while divide by 255 shits all over the whole float
- yongjik 5mo agoIf your input is an arbitrary float, you need to check for denormals (and maybe NaNs). You can do bitmasking trick to avoid conditional jumps but I'm skeptical you can do it faster than SIMD multiply instruction.