Re: Bug with extended type?

Daniel Rail <[email protected]>
Newsgroups gmane.comp.lang.delphi.programming
Message-ID <[email protected]>
Hi,

At July 31, 2003, 18:25, michael_grimard wrote:
> The problem is that the comparison doesn't always work...

> if ConvertVersionAsExtended(1, 20) >= 1.20 then
>   Read;  // <-- I don't go here!!!

> I am suprised that ConvertVersionAsExtended(1, 20) returns 
> 1.19999999999999996 instead of 1.2, since it can (assign 1.2 in an 
> extended variable and check with the debugger, you will see that the
> value of the variable is still 1.2).
[...snip...]
> How can that happened?

Easy. A floating-point value is an approximate numeric value and not
an exact numeric value. If you want an exact numeric with decimals,
use the Currency type.  This behavior applies on how the CPU
floating-point processor deals with floating-point calculations, and
it's not specific to Delphi.

-- 
Best regards,
 Daniel Rail
 Senior System Engineer
 ACCRA Group Inc. (www.accra.ca)
 ACCRA Med Software Inc. (www.filopto.com)


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/sO0ANB/LIdGAA/ySSFAA/i7folB/TM
---------------------------------------------------------------------~->

CodeCoffer - new Delphi code protection Tool!
http://www.delphicollection.com/public/CodeCoffer.htm
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
--------------------------------------------------------------- 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.