I think you're right. The code below produces 229999

procedure TForm1.Button1Click(Sender: TObject);
var
  d: double;
begin
  d := 2.3;
  caption := IntToStr( trunc( d * 10 * 10 * 10 * 10 *
10) );
end;




--- Rob Kennedy <[EMAIL PROTECTED]> wrote:

> 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! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/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