Board index » delphi » String Result
Chekcin
Delphi Developer |
Chekcin
Delphi Developer |
String Result2005-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 |
Florent Ouchet
Delphi Developer |
2005-05-01 03:58:00 PM
Re:String Result
Chekcin a écrit :
QuoteHi 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 |