您的位置:首页 > 编程语言 > Delphi

DELPHI DOUBLE不解之迷

2020-03-01 21:06 344 查看

procedure TForm1.cmd2Click(Sender: TObject);
var
str1, str2: string;
LValue1: Double;
LValue2: Extended;
LFactor1: Double;
LFactor2: Extended;
begin
LFactor1 := 0.1;
LFactor2 := 0.1;
LValue1 := 0.15;
LValue2 := 0.15;
LValue1 := (LValue1 / LFactor1) + 0.5;
LValue2 := (LValue2 / LFactor2) + 0.5;
LValue1 := Int(LValue1);                    //为什么Int(2)=1???
LValue2 := Int(LValue2);
LValue1 := LValue1 * LFactor1;
LValue2 := LValue2 * LFactor2;
str1 := FloatToStr(LValue1);
str2 := FloatToStr(LValue2);
ShowMessage(str1 + '|' + str2);
end;

转载于:https://www.cnblogs.com/IDELPHI/p/6098857.html

  • 点赞
  • 收藏
  • 分享
  • 文章举报
VISION2015 发布了0 篇原创文章 · 获赞 0 · 访问量 183 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: