我如何提取一个双人的尾数 [英] how can I extract the mantissa of a double
问题描述
我想要存储一个变量mantisssa的双重
I would like to store in a variable the mantisssa of a double
我已经发布了一个代码来获得二进制代码:点击此处
I have post a code to get the binary representation of a double : click here
我应该更改为隔离尾数
推荐答案
在< math.h>
double frexp (double value, int *exp)
以指数和尾数分解VALUE。
decompose VALUE in exponent and mantissa.
double ldexp (double value, int exp)
相反。
一个整数值,您必须将frexp的结果乘以FLT_RADIX指数DBL_MANT_DIG(这些可用于< float.h>
。要将其存储在整数变量中,您还需要找到一个足够的类型(通常是64位类型)
To get an integer value, you have to multiply the result of frexp by FLT_RADIX exponent DBL_MANT_DIG (those are availble in <float.h>
. To store that in an integer variable, you also need to find an adequate type (often a 64 bits type)
如果你想处理128位长双倍的褶皱提供,您需要C99 frexpl进行分割,然后您可能没有足够的整数类型来存储完整结果。
If you want to handle the 128 bits long double some implementations provide, you need C99 frexpl to do the splitting and then you probably don't have an adequate integer type to store the full result.
这篇关于我如何提取一个双人的尾数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!