gpt4 book ai didi

fortran - double 的数量级

转载 作者:行者123 更新时间:2023-12-04 05:06:25 25 4
gpt4 key购买 nike

对于两个理论上相等的 double 数之间的减法,我应该期待什么数量级的差异?

我有两个 double 数组。预计它们在理论上是相同的。它们都是通过两种完全不同的方法计算的,因此它们之间存在一些数值差异。我逐个元素地检查它们,我的最大差异是
6.5557799910909154E-008。我的老板说,对于 double 来说,这是一个非常大的差异,但我认为如果差异是 E-008 的顺序,那就没问题了。

谢谢,
普拉迪普

最佳答案

Double precision floating point有以下格式

  • 符号位:1 位
  • 指数宽度:11 位
  • 有效位精度:53 位(52 位显式存储)

  • This gives from 15 - 17 significant decimal digits precision. If a decimal string with at most 15 significant decimal is converted to IEEE 754 double precision and then converted back to the same number of significant decimal, then the final string should match the original; and if an IEEE 754 double precision is converted to a decimal string with at least 17 significant decimal and then converted back to double, then the final number must match the original.



    Single precision floating point有以下格式
  • 符号位:1 位
  • 指数宽度:8 位
  • 有效位精度:24(显式存储 23)

  • This gives from 6 to 9 significant decimal digits precision (if a decimal string with at most 6 significant decimal is converted to IEEE 754 single precision and then converted back to the same number of significant decimal, then the final string should match the original; and if an IEEE 754 single precision is converted to a decimal string with at least 9 significant decimal and then converted back to single, then the final number must match the original.



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

    你知道这两种方法哪个更准确吗?主要区别是计算速度和精度之间的权衡还是其中一种算法在数值上不太稳定?输入的精度是多少?如果您的输入不那么精确,那么 8 位小数精度的差异可能无关紧要……或者这可能意味着在行星轨道上丢失了火星。

    关于fortran - double 的数量级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15493263/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com