What is the purpose of ldexp?

I was curious that people use the ldexp () function for practical applications.

This description:

Returns the result of multiplying x (value) by 2, raised to the power exp (exponent).

+6
source share
2 answers

ldexp and its double, frexp , handle the mantissa and the floating-point exponent. They provide a way to get an internal representation without directly manipulating bits.

+4
source

When used with frexp , the ldexp function ldexp useful in situations requiring repeated multiplication by 2. If the next multiplication causes overflow or underuse, use frexp to branch the exponent mantissa. This gives you full control over the exhibitor and the mantissa, so you can work with them separately without losing accuracy. When you're done, use ldexp to combine the mantissa and the exponent again.

More details here .

+2
source

Source: https://habr.com/ru/post/947219/


All Articles