Log In    |    Knowledge Base    |    4D Home
Tech Tip: NANs (not a number) numeric values
Published On: May 19, 2000

One of the rules in computer science is to NEVER divide by zero. The result of dividing by zero in most applications is for the computer to crash. If you divide by zero in 4D it will usually return a NAN value. NAN stands for "Not A Number". A NAN has a number that will return odd results in programming operations. For example, a search might return an incorrect selection of records. The if statement below shows you the logic to use to determine if a value is a NAN. The logic of this if statement can also be applied to QUERY BY FORMULA for searching records.

Note: 4D will not usually crash when attempting to divide by zero however it is wise to avoid performing a divide by zero since there are no guarantees that your database will never crash during this operation.

Here is a text copy of the code shown above for you to cut-and-paste into your own project:

vNAN:=0/0  ` lets make a NAN

If (String(vNan)="")
 ALERT("Congratulations, you just created a NAN.")
End if