I found reading this description clunky.
Overflow will produce infinity. The result will be zero rather than a
subnormal number in case of underflow, regardless of control bits in
the mask or numeric control register.
Can I suggest changing the second sentence to match the structure of the first:
Overflow produces infinity. Underflow produces zero rather than a
subnormal number in case of underflow, regardless of control bits in
the mask or numeric control register.
Does this means that if I have code like
let x = 0x1.0p-1022 * 0.25
that I will get a value of 'x' which is zero? Probably not what I would prefer.
Or, if the use of that instruction intended to be dependent on compiler options.
Or have I misunderstood things.
Is there an instruction which behaves as IEEE 754's 'scalbn'
Underflow/Overflow in mul_2pow
Moderator: agner
Re: Underflow/Overflow in mul_2pow
The main purpose of the mul_2pow instruction is to improve speed. x * 0.25 will take several clock cycles. With optimization on, the compiler or assembler can change x*0.25 to mul_2pow(x, -2) which takes only 1 clock cycle. It would be difficult to do this in a single clock cycle if you want underflow to produce a subnormal number.
Apart from not supporting subnormal numbers, I think this instruction behaves like scalbn. Can you spot any difference?
Apart from not supporting subnormal numbers, I think this instruction behaves like scalbn. Can you spot any difference?
Re: Underflow/Overflow in mul_2pow
Understand the reasoning for speed. If I am ever lucky enough to have hardware based on this instruction set, I will just have to be careful to protect myself if I want to avoid flushing to zero. I was curious if you could use a template with an option to enable/disable such flushing to zero.
And yes, the instruction behaves the same as scalbn except for subnormal results.
And yes, the instruction behaves the same as scalbn except for subnormal results.