更精确的浮点数据类型比双精度? [英] More Precise Floating point Data Types than double?

查看:617
本文介绍了更精确的浮点数据类型比双精度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我必须计算除法,乘法,减法,添加到 double 元素的矩阵。
问题是,当矩阵的大小增加时,我的输出的准确性急剧受到影响。
目前我使用 double 为每个元素,我相信使用 8字节的内存&具有 16位数的精度,与小数位置无关。
即使对于大型矩阵,所有元素占用的内存也在几千字节的范围内。所以我可以使用数据类型,这需要更多的内存。
所以我想知道哪个数据类型比 double 更精确。
我试图在一些书&我可以找到 long double
但是我不知道它的精度是什么。

根据维基百科的说法,80位的IntelIEEE(美国电气工程师协会) 754 extended-precision long double ,这是80位填充到16字节在内存中,有64位尾数,没有隐式位,这将得到你的19.26十进制数。这是 long double 几乎普遍的标准,但最近的事情已经开始改变。



较新的128位四精度格式具有112尾数位加上一个隐式位,它可以得到34个十进制数字。 GCC实现这个作为 __ float128 类型,并且有(如果内存服务)编译器选项设置 long double


In my project I have to compute division, multiplication, subtraction, addition on a matrix of double elements. The problem is that when the size of matrix increases the accuracy of my output is drastically getting affected. Currently I am using double for each element which I believe uses 8 bytes of memory & has accuracy of 16 digits irrespective of decimal position. Even for large size of matrix the memory occupied by all the elements is in the range of few kilobytes. So I can afford to use datatypes which require more memory. So I wanted to know which data type is more precise than double. I tried searching in some books & I could find long double. But I dont know what is its precision. And what if I want more precision than that?

解决方案

According to Wikipedia, 80-bit "Intel" IEEE 754 extended-precision long double, which is 80 bits padded to 16 bytes in memory, has 64 bits mantissa, with no implicit bit, which gets you 19.26 decimal digits. This has been the almost universal standard for long double for ages, but recently things have started to change.

The newer 128-bit quad-precision format has 112 mantissa bits plus an implicit bit, which gets you 34 decimal digits. GCC implements this as the __float128 type and there is (if memory serves) a compiler option to set long double to it.

这篇关于更精确的浮点数据类型比双精度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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