Floating Point Numbers

From BR Wiki
Jump to: navigation, search

Floating point numbers are numbers which allow the decimal point to "float" to any position.

The Business Rules syntax is nEm, where n is a numeric constant indicating the sign and significant digits in the number, E represents base 10, and m is a signed integer representing the power to which 10 is raised.

The largest and smallest numbers available to the system vary according to the hardware and operating system being used. The system function INF can be used to print the largest possible number on any given system; 1/INF generates the smallest number. Some caution should be used in working with numbers near these minimum and maximum extremes (e.g., using exponential notation in SORT). Also, for any given combination of hardware and Business Rules, the system infinity function INF and some testing should be combined to determine whether or not intermediate values used in calculations will be truncated.

All numbers in memory are floating point numbers. The form of the number when written to disk or printed depends on the format or mask used in writing the number. Number variables are designated by NOT ending with a dollar sign in Business Rules.

The fact that floating-point numbers cannot precisely represent all real numbers, and that floating-point operations cannot precisely represent true arithmetic operations, leads to many surprising situations. This is related to the finite precision with which computers generally represent numbers. in BUsiness Rules, floating point numbers can only provide 16 digits of precision, this is before or after the decimal place.


Values that fit in Floating Point: print using 'form n 20.2':1234567890123.45 --> 1234567890123.45 print using 'form n 20.8':1234567.89012345 --> 1234567.89012345

Values that do not fit in Floating Point: print using 'form n 20.2':123456789012345.67 --> 123456789012346.00 print using 'form n 20.8':1234567890.1234567 --> 1234567890.12346000