This does not look like Inno Setup question, but is actually related to its useful Pascal Script.
I wrote a code to do a floating point calculation.
Height, DivisionOfHeightWidth, Width: Integer;
Height := 1080;
Width := 1920;
DivisionOfHeightWidth := Width / Height;
Log('The Division Of Height and Width: ' + IntToStr(DivisionOfHeightWidth));
Compiler log gives the output:
The Division Of Height and Width: 1
I want this compiler output to return this instead:
The Division Of Height and Width: 1.77
I can't declare Height
and Width
as Extended , Single
or Double
as they are returning as Integer
in most situations, so I need to convert those two Integers to two Singles.
After doing it:
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));
Compiler log now gives the output:
The Division Of Height and Width: 1.777777791023
But how can I get this output as 1.77
? (Not 1.78
by Rounding)
I mean how can I round this 1.777777791023
to two decimal places like 1.77
?
If rounding it like 1.77
is impossible to do, how can I round it like 1.78
?
Thanks in advance.