这看起来不像Inno Setup问题,但实际上与其有用的Pascal脚本有关。在Inno Setup Pascal脚本中将浮点数舍去到N个小数位
我写了一个代码来做浮点计算。
Height, DivisionOfHeightWidth, Width: Integer;
Height := 1080;
Width := 1920;
DivisionOfHeightWidth := Width/Height;
Log('The Division Of Height and Width: ' + IntToStr(DivisionOfHeightWidth));
编译器日志给出了输出:
The Division Of Height and Width: 1
我想这个编译器的输出,而不是返回此:
The Division Of Height and Width: 1.77
我不能宣布Height
和Width
为Extended , Single
或Double
因为他们在大多数情况下返回Integer
,所以我需要转换这两个整数到两个单打。
做后:
Height, Width: Integer;
HeightF, WidthF, DivisionOfHeightWidthF: Single;
Height := 1080;
Width := 1920;
HeightF := Height;
WidthF := Width;
DivisionOfHeightWidthF := WidthF/HeightF;
Log('The Division Of Height and Width: ' + FloatToStr(DivisionOfHeightWidthF));
编译器日志现在给人的输出:
The Division Of Height and Width: 1.777777791023
但我怎么能得到这个输出1.77
? (不是1.78
通过舍入) 我的意思是我怎么能把这个1.777777791023
舍入到小数点后两位,如1.77
?
如果四舍五入就像1.77
是不可能做到的,我怎么能像1.78
那样围绕它?
在此先感谢。
我用你的实现,而不是格式化字符串。它工作得很好!谢谢!........我很幸运,因为我总是使用Inno Setup Unicode Version .....;) – GTAVLover