将数字分配给Double或Extended变量时,为什么会得到不正确的值?

我需要将值分配给线性,但是当我检查它时,结果是错误的。表达式1/exp( 2.30258509299 * (abs(dB)/20) )的结果是0,063095734448(这是正确值),但线性是-3,6854775808e + 4863,n是1,805186914e-307。

unit Unit1;

interface

uses
  Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;

type
  TForm1 = class(TForm)
  procedure OnCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.OnCreate;
var dB: integer;
    linear: extended;
    n: Double;
begin
  dB := -24;
  linear := 1/exp( 2.30258509299 * (abs(dB)/20) );
  n := 0.063095734448;
  showmessage(inttostr(db));
end;


end.

我在做什么错了,如何获得正确的值?

注意:为了评估表达式,我使用了调试器“评估/修改”命令。

将数字分配给Double或Extended变量时,为什么会得到不正确的值?

worinima1 回答:将数字分配给Double或Extended变量时,为什么会得到不正确的值?

很可能您已启用编译器优化,并且编译器认识到变量isWinnerfor(int i=0; i<size; i++){ boolean flag = true; // Assume this line is a winning line for(int j=0; j<size; j++){ // Check each tile to see if it has a tile // Set the flag to false when it is not the tile you're looking for } } 已分配给变量,但随后从未读取。因此,在分配这些变量后,编译器无需保留这些变量。

尝试此代码

linear
本文链接:https://www.f2er.com/3127473.html

大家都在问