mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 15:49:35 +02:00
+ Fixed float<>string conversion routines
This commit is contained in:
parent
cdf2d7408e
commit
bfd3e76ccf
@ -994,16 +994,27 @@ begin
|
||||
Result:=Buffer;
|
||||
end;
|
||||
|
||||
Function StrToFloat(Const S: String): Extended;
|
||||
|
||||
function StrToFloat(Value: string): Extended;
|
||||
Begin
|
||||
If Not TextToFloat(Pchar(S),Result) then
|
||||
Raise EConvertError.createfmt(SInValidFLoat,[S]);
|
||||
End;
|
||||
|
||||
Function TextToFloat(Buffer: PChar; Var Value: Extended): Boolean;
|
||||
|
||||
var Error: word;
|
||||
Var
|
||||
E,P : Integer;
|
||||
S : String;
|
||||
|
||||
begin
|
||||
Val(Value, result, Error);
|
||||
if Error <> 0 then raise
|
||||
EConvertError.createfmt(SInValidFLoat,[Value]);
|
||||
end ;
|
||||
Begin
|
||||
S:=StrPas(Buffer);
|
||||
P:=Pos(DecimalSeparator,S);
|
||||
If (P<>0) Then
|
||||
S[P] := '.';
|
||||
Val(S,Value,E);
|
||||
Result:=(E=0);
|
||||
End;
|
||||
|
||||
Function FloatToStr(Value: Extended): String;
|
||||
Begin
|
||||
@ -1758,12 +1769,11 @@ End;
|
||||
Function FormatFloat(Const format: String; Value: Extended): String;
|
||||
|
||||
Var
|
||||
Temp: shortstring;
|
||||
Temp: ShortString;
|
||||
buf : Array[0..1024] of char;
|
||||
|
||||
Begin
|
||||
Temp := format;
|
||||
Buf[FloatToTextFmt(@Buf[0],Value,@Temp)]:=#0;
|
||||
Buf[FloatToTextFmt(@Buf[0],Value,Pchar(Format))]:=#0;
|
||||
Result:=StrPas(@Buf);
|
||||
End;
|
||||
|
||||
@ -1922,7 +1932,10 @@ const
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.22 2002-11-28 20:29:26 michael
|
||||
Revision 1.23 2002-11-28 22:26:30 michael
|
||||
+ Fixed float<>string conversion routines
|
||||
|
||||
Revision 1.22 2002/11/28 20:29:26 michael
|
||||
+ made it compile again
|
||||
|
||||
Revision 1.21 2002/11/28 20:15:37 michael
|
||||
@ -1930,6 +1943,11 @@ const
|
||||
|
||||
Revision 1.20 2002/09/15 17:50:35 peter
|
||||
* Fixed AnsiStrComp crashes
|
||||
Revision 1.1.2.16 2002/11/28 22:25:01 michael
|
||||
+ Fixed float<>string conversion routines
|
||||
|
||||
Revision 1.1.2.15 2002/11/28 20:24:11 michael
|
||||
+ merged some fixes from mainbranch
|
||||
|
||||
Revision 1.19 2002/09/07 16:01:22 peter
|
||||
* old logs removed and tabs fixed
|
||||
|
@ -102,7 +102,8 @@ Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Arra
|
||||
Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
|
||||
Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
|
||||
Function FloatToStr(Value: Extended): String;
|
||||
Function StrToFloat(Value : String) : Extended;
|
||||
Function StrToFloat(Const S : String) : Extended;
|
||||
Function TextToFloat(Buffer: PChar; Var Value: Extended): Boolean;
|
||||
Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
|
||||
Function FloatToDateTime (Const Value : Extended) : TDateTime;
|
||||
Function FloattoCurr (Const Value : Extended) : Currency;
|
||||
@ -145,11 +146,17 @@ function BCDToInt(Value: integer): integer;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.13 2002-11-28 20:29:26 michael
|
||||
Revision 1.14 2002-11-28 22:26:30 michael
|
||||
+ Fixed float<>string conversion routines
|
||||
|
||||
Revision 1.13 2002/11/28 20:29:26 michael
|
||||
+ made it compile again
|
||||
|
||||
Revision 1.12 2002/09/07 16:01:22 peter
|
||||
* old logs removed and tabs fixed
|
||||
Revision 1.1.2.6 2002/11/28 22:25:01 michael
|
||||
+ Fixed float<>string conversion routines
|
||||
|
||||
Revision 1.1.2.5 2002/11/28 20:24:12 michael
|
||||
+ merged some fixes from mainbranch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user