Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FloatToDecimal quickie

66 views
Skip to first unread message

Les Piotrowski

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
Im trying to convert a float to decimal (currency) but am having problems
with the syntax,
Var
FloatVal:Double;
DecVal:Currency;
Begin
FloatToDecimal (FloatVal,DecVal,Currency,18,2);
End;

This doesnt work,,,,it must be my syntax....can anyone help?

David

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to

What about :

var
FloatValue, FloatResult: Double;
begin
FloatResult := FormatFloat('###,##0.00', FloatValue);
end;

Philippe Ranger

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
Les: >>

Im trying to convert a float to decimal (currency) but am having problems
with the syntax,
Var
FloatVal:Double;
DecVal:Currency;
Begin
FloatToDecimal (FloatVal,DecVal,Currency,18,2);
End;
<<

FloatToDecimal is normally called only inside complex formatting routines;
it handles the basic float-to-char conversion. To do that, it uses a special
return record format has its first parameter. The above code is not at all
what's needed (the third param is wrong too). But, more important, whatever
it is you're trying to do, FloatToDecimal isn't going to do it.

Could it be that all you want is —

myCurrency := myDouble;

where myCurrency is of type Currency and myDouble of any ordinary float
type, e.g. Double?

PhR

Graham

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
Try

Var
FloatVal:TFloatRec; // <<<< TFloatRec not Double
DecVal:Currency;
Begin
FloatToDecimal(FloatVal,DecVal,fvCurrency,18,2); // fvCurrency as param not
Currency
end;

Check help on TFloatRec and TFloatValue to find out more about the proper
parameter data types that must be given to FloatToDecimal.

Respectfully yours,
graham

Les Piotrowski wrote in message <74oh3s$e0...@forums.borland.com>...


>Im trying to convert a float to decimal (currency) but am having problems
>with the syntax,
>Var
>FloatVal:Double;
>DecVal:Currency;
>Begin
>FloatToDecimal (FloatVal,DecVal,Currency,18,2);
>End;
>

0 new messages