Walter  Prins wrote:
> I'm having a blonde moment here, or this is a strange bug...  Can anyone
> point out what I'm missing: why the following test-case produces a label
> with a caption of '22' and not '23'????   Or is this just a case of
> floating
> point imprecision?  (To reproduce create a new project, drop a button and
> a
> label on a form and replace the click event handler with the following:)
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
>   d : Double;
> begin
>   d := 2.3;

The value of d is not exactly 2.3. Its value is probably 2.299...

There are some projects on CodeCentral by John Herbster that will show the
exact value of a Single, and Double, or an Extended.

If you do the multiplication before the assignment,

d := 2.3 * 10;

then the compiler performs that operation in advance, treating them as
Extended, not as Double. If you assign 2.3 to the Double value, then you
force the operation to be done using Double instead of Extended.

-- 
Rob




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to