Board index » delphi » limiting the number of decimal places

limiting the number of decimal places

How do I limit the number of decimal places in a calculation
X := depos.text;
Result1 := X-(X*pofsle/100);
Result2 := Result1-(Result1*avlmkt/100);
Poscalc := Result2-(Result2*prepay/100);
laPoscalc.Caption := Poscalc;

Poscalc is a currency variant & I want to limit to 2 decimal places.
Can anybody help??

Thankyou.

 

Re:limiting the number of decimal places


Try

function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision,
  Digits: Integer): string;

X : Extended;

X := StrToFloat(depos.text);
Result1 := X-(X*pofsle/100);
Result2 := Result1-(Result1*avlmkt/100);
Poscalc := Result2-(Result2*prepay/100);
laPoscalc.Caption := FloatToStrF(Poscalc,ffCurrency , 10, 2);

Roger

Quote
Roberta Viant wrote in message <35D6C91E.6FD89...@one.net.au>...
>How do I limit the number of decimal places in a calculation
>X := depos.text;
>Result1 := X-(X*pofsle/100);
>Result2 := Result1-(Result1*avlmkt/100);
>Poscalc := Result2-(Result2*prepay/100);
>laPoscalc.Caption := Poscalc;

>Poscalc is a currency variant & I want to limit to 2 decimal places.
>Can anybody help??

>Thankyou.

Other Threads