如何提取双精度的尾数 [英] how can I extract the mantissa of a double

查看:145
本文介绍了如何提取双精度的尾数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想存储在一个变量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

我应该如何变更以隔离尾数

What should I change to isolate the mantissa

推荐答案

< math.h>

double frexp (double value, int *exp)

以指数和尾数分解值。

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位长的double一些实现提供,你需要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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆