advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Tip formerly from VB2TheMax
Expertise: Intermediate
Language: VB4,VB5,VB6
May 20, 2000
Understanding the "Allow Unrounded Floating Point Operations" option
The Microsoft manuals preach that all the compiler options in the Advanced Optimization dialog box are to be considered unsafe, in that they might lead to incorrect results (or just program crashes!). This is true for most of them, but often one of such options - namely, the "Allow Unrounded Floating Point Operations" - can deliver correct results and prevent you from inserting a bug in your application. Consider the following code:


Dim x As Double, y As Double, i As Integer
x = 10 ^ 18
y = x + 1 ' this can't be expressed with 64 bits
MsgBox (y = x) ' displays "True" (uncorrect)
Strictly speaking, the MsgBox should display False, because the X and Y variables shouldn't contain the same value. The problem is, they do contain exactly the same value, because the values 1E18 e 1E18+1 are represented with the same 64-bit floating point Double value.

It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?





Francesco Balena
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
advertisement
advertisement