[Lazarus] procedure FloatToDecimal
rlaurie at gmail.com
Mon Sep 1 07:29:39 CEST 2008
Procedure FloatToDecimal(Out Result: TFloatRec; Value: Extended; Precision,
Decimals : integer);
The Precision, and Decimals work together to ensure the rounding etc.
So lets say you want to have float to decimal, and have 5 "digits"... And
you do it on a value of 2 then the result will be
If you only want a precision 2 but want decimals 5, and run it for pi, you
So general rule is to have your precision higher than your digits, and
you'll have good "rounding".
Hmmm... My test program shows some funnies:
procedure TForm1.FormDblClick ( Sender : TObject ) ;
var t : TFloatRec;
Shows 3.1432 -- not 3.143 as expected...
(not 3.140000) as I expected...
On Sat, Aug 30, 2008 at 4:19 AM, Héctor Fiandor Rosario <
hfiandor at infomed.sld.cu> wrote:
> Dear sirs:
> I need to convert a Float to a number with two decimal places in a Lazarus
> Project for Windows..
> I am thinking to use the following procedure:
> Procedure FloatToDecimal(Out Result: TFloatRec; Value: Extended; Precision,
> Decimals : integer);
> but I dont know what to write in some of the arguments.
> Thanks in advance for your help,
> yours truly,
> Ing. Héctor F. Fiandor
> hfiandor at infomed.sld.cu
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
...speed is good
I believe five out of four people have a problem with fractions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus