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:

strtof, ftostr


Part

Description

num

Variable to check.


Details

Floating-point calculations can lead to an 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 the correct value. This is where the cfloat function comes in 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

cfloat Function

Details

Examples