Re: Bug with extended type?

"Rory Daulton" <[email protected]>
Newsgroups gmane.comp.lang.delphi.programming
Message-ID <002c01c357ac$17e634a0$6501a8c0@laptop>
Michael,

>   I have a function in a shared utility that I use to convert the
> major version and minor version to an extended type.

That is the problem in working with floating-point types, the exact values
you get are highly dependent on the calculations, their order, and the type
of intermediate variables.

The best thing is to avoid the floating point type.  Just the day before
yesterday I wrote a routine to get a number for the version of Windows
currently running, and I wrote it to avoid floating point types.  I stuffed
the minor version number into the least significant byte of an integer, the
major version into the next byte, and the ID (platform type) into the next
byte.  That is working well for me.

If you must use floating point types such as Extended, never test for
equality or for exact tests like
  ConvertVersionAsExtended(1, 20) >= 1.20
Instead, use something like
  ConvertVersionAsExtended(1, 20) >= 1.19995

Then, even if the result is slightly below 1.20 the test will work as you
want.

Rory Daulton
[email protected]


---
[This E-mail scanned for viruses by Declude Virus and Nmax "Your MAXimum Connection!"]
[This E-mail scanned for spam by Declude JunkMail and Nmax "Your MAXimum Connection!"] 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Free shipping on all inkjet cartridge & refill kit orders to US & Canada. Low prices up to 80% off. We have your brand: HP, Epson, Lexmark & more.
http://www.c1tracking.com/l.asp?cid=5510
http://us.click.yahoo.com/GHXcIA/n.WGAA/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.