<div dir="ltr">Procedure FloatToDecimal(Out Result: TFloatRec; Value: Extended; Precision, Decimals : integer);<br><br>The Precision, and Decimals work together to ensure the rounding etc. <br><br>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<br>
2.00000<br><br>If you only want a precision 2 but want decimals 5, and run it for pi, you will get<br>3.14000<br><br>So general rule is to have your precision higher than your digits, and you'll have good "rounding".<br>
<br>Hmmm... My test program shows some funnies:<br><br>procedure TForm1.FormDblClick ( Sender : TObject ) ;<br>var t : TFloatRec; <br>begin<br> FloatToDecimal(t,pi,5,3);<br> ShowMessage(inttostr(t.Exponent)+'.'+t.Digits);<br>
end; <br><br>Shows 3.1432 -- not 3.143 as expected...<br><br>FloatToDecimal(t,pi,2,6);<br>Showed, 3.14<br><br>(not 3.140000) as I expected...<br><br><br><br><div class="gmail_quote">On Sat, Aug 30, 2008 at 4:19 AM, Héctor Fiandor Rosario <span dir="ltr"><<a href="mailto:hfiandor@infomed.sld.cu">hfiandor@infomed.sld.cu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear sirs:<br>
<br>
I need to convert a Float to a number with two decimal places in a Lazarus<br>
Project for Windows..<br>
<br>
I am thinking to use the following procedure:<br>
<br>
Procedure FloatToDecimal(Out Result: TFloatRec; Value: Extended; Precision, Decimals : integer);<br><br>begin<br> FloatToDecimal(Result,Value,fvExtended,Precision,Decimals);<br>end;<br>
<br>
but I dont know what to write in some of the arguments.<br>
<br>
Thanks in advance for your help,<br>
<br>
yours truly,<br>
<br>
Ing. Héctor F. Fiandor<br>
<a href="mailto:hfiandor@infomed.sld.cu">hfiandor@infomed.sld.cu</a><br>
<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lazarus.freepascal.org">Lazarus@lazarus.freepascal.org</a><br>
<a href="http://www.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://www.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>o__<br>,_.>/ _<br>(_)_\(_)_______<br>...speed is good<br>_______________<br>I believe five out of four people have a problem with fractions.<br>
</div>