Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 20

Allowing Unrounded Floating-Point Operations, Removing Safe Pentium FDIV Checks

Allowing Unrounded Floating-Point Operations

This is another floating-point optimization. It applies when a VB program compares the values of floating-point variables in the evaluation of conditional expressions. Because the variables being compared may not be of the same type, the compiler performs a rounding operation prior to the actual comparison. This enables it to compare like types to one another. For example:

Dim singleValue as Single, doubleValue as Double
singleValue = 1
doubleValue = 1
If singleValue = doubleValue Then
‘ do something
End If

Before comparing the values, singleValue is rounded up to the same precision as doubleValue. Otherwise, the compiler might decide that 1.000000 doesn’t equal 1.00000000000000, which would be confusing.

The rounding process takes some extra time, so this optimization enables you to turn it off. You can avoid any problems this may cause by making sure that you compare variables that are already the same type as one another.

Removing Safe Pentium FDIV Checks

This is yet another floating-point optimization. Some of Intel’s early Pentium chips had a bug that affected certain floating-point division calculations. By default, VB’s mathematical routines guard against the Pentium bug, but doing the math in VB code is slower than letting the processor chip do it for you. If you are confident that your programs won’t run on a machine with the Pentium FDIV bug, you may want to activate this optimization.


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved