| SciFloat2EStr2 Routines |
Unit
QESBPCSConvert
| Overloaded Variants |
Declaration
Function SciFloat2EStr2(const X: Extended; const Decimals: Byte = 4): string;
Description
This is of the form d.dddEnn. ESBBlankWhenZero can be set to True to have Zero returned as an Empty string, where Zero is dependent upon ESBTolerance.
| Parameters |
| X | Value to Convert to String. |
| Decimals | is the desired number of Decimal places in the Mantissa, defaults to 4 |
Category
String/Float Conversion RoutinesImplementation
function SciFloat2EStr2 (const X: Extended; const Decimals: Byte = 4): string;
var
P: Integer;
S1, S2: string;
begin
if ESBBlankWhenZero and FloatIsZero (X) then
begin
Result := '';
Exit;
end;
try
Result := FloatToStrF (X, ffExponent, Decimals + 1, 0);
P := ESBPosCh ('E', Result);
if P > 0 then
begin
S1 := LeftStr (Result, P - 1);
S2 := RightAfterStr (Result, P - 1);
S1 := StripTChStr (S1, '0');
if S1 [Length (S1)] = '.' then
S1 := LeftStr (S1, Length (S1) - 1);
Result := S1 + S2;
end;
except
Result := '';
end;
End; |
Declaration
Function SciFloat2EStr2(const X: Double; const Decimals: Byte = 4): string;Implementation
function SciFloat2EStr2 (const X: Double; const Decimals: Byte = 4): string;
var
P: Integer;
S1, S2: string;
begin
if ESBBlankWhenZero and FloatIsZero (X) then
begin
Result := '';
Exit;
end;
try
Result := FloatToStrF (X, ffExponent, Decimals + 1, 0);
P := ESBPosCh ('E', Result);
if P > 0 then
begin
S1 := LeftStr (Result, P - 1);
S2 := RightAfterStr (Result, P - 1);
S1 := StripTChStr (S1, '0');
if S1 [Length (S1)] = '.' then
S1 := LeftStr (S1, Length (S1) - 1);
Result := S1 + S2;
end;
except
Result := '';
end;
End; |
Declaration
Function SciFloat2EStr2(const X: Single; const Decimals: Byte = 4): string;Implementation
function SciFloat2EStr2 (const X: Single; const Decimals: Byte = 4): string;
var
P: Integer;
S1, S2: string;
begin
if ESBBlankWhenZero and FloatIsZero (X) then
begin
Result := '';
Exit;
end;
try
Result := FloatToStrF (X, ffExponent, Decimals + 1, 0);
P := ESBPosCh ('E', Result);
if P > 0 then
begin
S1 := LeftStr (Result, P - 1);
S2 := RightAfterStr (Result, P - 1);
S1 := StripTChStr (S1, '0');
if S1 [Length (S1)] = '.' then
S1 := LeftStr (S1, Length (S1) - 1);
Result := S1 + S2;
end;
except
Result := '';
end;
End; |
|
|