Float2CEStr Routines
Converts a Float into a string without Padding and with Thousands Separators.

Unit
QESBPCSConvert

Overloaded Variants
Function Float2CEStr(const X: Extended; const Decimals: Byte = 4): string;
Function Float2CEStr(const X: Double; const Decimals: Byte = 4): string;
Function Float2CEStr(const X: Single; const Decimals: Byte = 4): string;

Declaration
Function Float2CEStr(const X: Extended; const Decimals: Byte = 4): string;

Description
ESBNumPosSign controls whether a '+' Sign appears at the beginning for positive Integers. ESBBlankWhenZero can be set to True to have Zero returned as an Empty string, where Zero is dependent upon ESBTolerance. Also see Float2CEStr2, Float2Str & Float2EStr

Parameters
Value to Convert to String.
Decimals is the desired number of Decimal places, defaults to 4

Category
String/Float Conversion Routines

Implementation

function Float2CEStr (const X: Extended; const Decimals: Byte = 4): string;
begin
     if ESBBlankWhenZero and FloatIsZero (X) then
     begin
          Result := '';
          Exit;
     end;

     try
          Result := FloatToStrF (X, ffNumber, 18, Decimals);
          if ESBNumPosSign and (X > 0) then // See if '+' needed
               Result := '+' + Result;
     except
          Result := '';
     end;
End;

Declaration
Function Float2CEStr(const X: Double; const Decimals: Byte = 4): string;

Implementation

function Float2CEStr (const X: Double; const Decimals: Byte = 4): string;
begin
     if ESBBlankWhenZero and FloatIsZero (X) then
     begin
          Result := '';
          Exit;
     end;

     try
          Result := FloatToStrF (X, ffNumber, 15, Decimals);
          if ESBNumPosSign and (X > 0) then // See if '+' needed
               Result := '+' + Result;
     except
          Result := '';
     end;
End;

Declaration
Function Float2CEStr(const X: Single; const Decimals: Byte = 4): string;

Implementation

function Float2CEStr (const X: Single; const Decimals: Byte = 4): string;
begin
     if ESBBlankWhenZero and FloatIsZero (X) then
     begin
          Result := '';
          Exit;
     end;

     try
          Result := FloatToStrF (X, ffNumber, 7, Decimals);
          if ESBNumPosSign and (X > 0) then // See if '+' needed
               Result := '+' + Result;
     except
          Result := '';
     end;
End;


HTML generated by Time2HELP
http://www.time2help.com