本文介绍了双精度量级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在两个理论上相等的双精度数之间进行减法时,我应该预期哪个数量级的差异?

我有两个双精度数组。预计它们在理论上是相同的。它们都是由两种完全不同的方法计算出来的,所以它们之间有一些数值上的差异。我逐个检查了它们,我的最大差异是
6.5557799910909154E-008。我的老板说,对于双精度这是一个非常高的差异,但我认为,如果E-008的顺序如果差别,那么它的好。

谢谢,
Pradeep

解决方案

具有以下格式:


  • 符号位:1 bit

  • 指数宽度:11位

  • 显着性和精确性:53位(显式存储52)

    具有以下格式


    • 符号位:1位
    • 指数宽度:8位
    • 显着性和精确性:24(显式存储23)



    • 您遇到的最大差异表示类似于转换为单精度的精度损失。 p>

      你知道哪两种方法更准确吗?它是计算速度与精度之间的一个折衷,它是主要区别还是算法之一在数值上不太稳定?输入的精度是多少?如果您的输入不是那么精确,那么精度的8位小数的差值可能不相关......或者它可能意味着行星轨迹上没有火星。


      What order of magnitude difference should I be expecting for a subtraction between two theoretically equal double precision numbers?

      I have two double precision arrays. They are expected to be theoretically same. They are both calculated by two completely different methodologies, so there is some numerical difference between them. I checked them element by element and my maximum difference is coming out to be6.5557799910909154E-008. My boss says that for a double precision this is a very high difference, but I thought that if the difference if of the order of E-008, then its alright.

      Thank you,Pradeep

      解决方案

      Double precision floating point has the following format

      • Sign bit: 1 bit
      • Exponent width: 11 bits
      • Significand precision: 53 bits (52 explicitly stored)

      Single precision floating point has the following format

      • Sign bit: 1 bit
      • Exponent width: 8 bits
      • Significand precision: 24 (23 explicitly stored)

      The maximum difference you are encountering indicates a loss of precision akin to converting to single precision.

      Do you know which of the two methods is more accurate? Is it a trade-off between speed of computation and precision that is the main difference or is one of the algorithms less numerically stable? What is the precision of the inputs? A difference of 8 decimal digits of precision may not be relevant if your inputs aren't that precise... or it could mean missing Mars on a planetary trajectory.

      这篇关于双精度量级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 04:41