Float2CStr Routines
Converts a Float into a string of length Len with ESBNumPadCh Padding to the Left and with Thousands Separators.

Unit
QESBPCSConvert

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

Declaration
Function Float2CStr(const X: Extended; const Len: Byte; 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 Float2EStr, Float2Str & Float2ZStr

Parameters
Value to Convert to String.
Len is the length of the resultant string. If it is too small then valid digits will be truncated from the right.
Decimals is the desired number of Decimal places, defaults to 4

Category
String/Float Conversion Routines

Implementation

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

     Result := PadChLeftStr (LeftStr (Float2CEStr (X, Decimals), Len), ESBNumPadCh, Len);
End;

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

Implementation

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

     Result := PadChLeftStr (LeftStr (Float2CEStr (X, Decimals), Len), ESBNumPadCh, Len);
End;

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

Implementation

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

     Result := PadChLeftStr (LeftStr (Float2CEStr (X, Decimals), Len), ESBNumPadCh, Len);
End;


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