# Rounding

## Rounding On|Off

This command turns internal rounding On or Off. By default rounding is On. Normally all numbers are rounded to 12 decimal places to the right of the decimal point. This is done to correct a problem with binary floating point storage. The problem stems from the fact that numbers like 0.1 can not be represented exactly in binary. As repeated mathematic operations are performed small errors occur and build up. This problem occurs on all computers unless rounding is performed. Internally numeric variables are stored as double floating point which is capable of storing up to 15 decimal places to the right of the decimal point. By rounding off the last 3 places the error is corrected. This makes basic match the results you would expect from a calculator.

This command was added for cases where the full range of a double floating point variable is needed (as in Scientific and Engineering applications for example). With Rounding Off, the maximum value that can be stored in a variable is 1.7976931348623157E308. The minimum value that can be stored in a variable with Rounding Off is 4.9E-324. For most cases rounding should always be turned on, especially when working with money.

Try this example if you want to see the effect of turning rounding off.

Rounding Off

a = 0

For i=1 to 100

a = a + 0.1

Print a

Next i