Skip to content

Commit

Permalink
Conversion: ftos - Rounding to an integer when RoundTo <= 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdp committed Jun 16, 2022
1 parent da6d022 commit 5603402
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Base/JPL.Conversion.pas
Original file line number Diff line number Diff line change
Expand Up @@ -537,17 +537,17 @@ function stof(s: string; ErrorValue: Real): Real;

function ftos(xr: Extended; RoundTo: integer = 2; DSep: string = ''): string;
var
s, mask: string;
s, FormatMask: string;
i: integer;
begin

if Round(xr) = xr then
s := IntToStr(Round(xr))
else
begin
mask := StringOfChar('0', RoundTo);
mask := '0.' + mask;
s := FormatFloat(mask, xr);
if RoundTo <= 0 then FormatMask := ''
else FormatMask := '0.' + StringOfChar('0', RoundTo);
s := FormatFloat(FormatMask, xr);
for i := Length(s) downto 1 do
begin
if s[i] <> '0' then Break;
Expand Down

0 comments on commit 5603402

Please sign in to comment.