Board index » delphi » String Result

String Result


2005-05-01 12:18:11 PM
delphi123
Hi
The INtToStr thread has some nice discussion. Thanks to all for their input.
How about a FLoatToStr, Frac, etc ?
Does anybody have this yet ?
Best Regards
X
 
 

Re:String Result

Chekcin a écrit :
Quote
Hi
The INtToStr thread has some nice discussion. Thanks to all for their input.
How about a FLoatToStr, Frac, etc ?
Does anybody have this yet ?
There is no significant improvements to be expected if only one value is
calculated at a time.
Some weeks ago, I started writting such a function:
procedure ExpandFloat(Value: Single; out Ceil: Integer; out Floor:
Integer; out Rnd: Integer; out Frac: Single); overload;
procedure ExpandFloat(Value: Double; out Ceil: Integer; out Floor:
Integer; out Rnd: Integer; out Frac: Double); overload;
procedure ExpandFloat(Value: Extended; out Ceil: Integer; out Floor:
Integer; out Rnd: Integer; out Frac: Extended); overload;
procedure ExpandFloat(Value: Single; out Ceil: Int64; out Floor: Int64;
out Rnd: Int64; out Frac: Single); overload;
procedure ExpandFloat(Value: Double; out Ceil: Int64; out Floor: Int64;
out Rnd: Int64; out Frac: Double); overload;
procedure ExpandFloat(Value: Extended; out Ceil: Int64; out Floor:
Int64; out Rnd: Int64; out Frac: Extended); overload;
I was not using any FPU instructions, because the most part of the code
to calculate Rnd, Ceil, Floor, Frac is redundant; calculating them
together is very fast.
I made a limitation for Extended numbers: they have to be normalized.
If anyone is interested in making a challenge on this calculation, the
benchmark tool should test :
- negative numbers below MinInt (Int64 only)
- numbers between MinInt and -1
- numbers between -1 and -0
- negative 0
- positive 0
- positive numbers between 0 and 1
- numbers between 1 and MaxInt
- numbers above MaxInt (Int64 only).
- some values like -Infinity, +Infinity and denormal numbers.
Regards,
Florent