cfloat Function
Function: |
Verifies whether the value of a floating-point variable is valid. Returns 0- VALID if the floating point value is OK, and 1- INVALID if the floating-point value is invalid. |
Syntax: |
cfloat(byref num as real) as valid_invalid |
See Also: |
Part |
Description |
num |
Variable to check. |
Details
Floating-point calculations can lead to invalid result (#INF, -#INF errors, as per IEEE specification). When your application is in the debug mode you will get a FPERR exception if such an error is encountered. In the release mode the Virtual Machine won't generate an exception, yet your application may need to know if a certain floating-point variable contains correct value. This is where cfloat function comes handy.
Examples
** Tibbo Basic **
dim r1 as real
dim v as invalid_valid
dim r1=10E30
v=cfloat(r1) 'v will return 0- VALID
r1=r1*10E20 'at this point you will get FPERR exception if you are in the debug mode
v=cfloat(r1) 'v will return 1- INVALID