Developer Documentation Library > Scripting > mrScriptBasic overview > mrScriptBasic language reference > General information > Understanding numbering systems
 
Understanding numbering systems
On occasion it is convenient to use hexadecimal numbers (base 16) or octal numbers (base 8). For example, color codes are often entered as hexadecimal numbers instead of decimal numbers. mrScriptBasic represents numbers in hexadecimal with the prefix &H and in octal with a prefix of &O (ampersand followed by the letter O).
For example, the number nine can be expressed in decimal format as 9, and in hexadecimal format as &H9. Both refer to the same value. The number ten can be expressed as 10 or &HA (where A is the hexadecimal digit that is one greater than 9). The number sixteen can be expressed as 16 or &H10, and so on.
The hexadecimal number &H14 is the same as the decimal number 20, because &H14 is 1 sixteen and 4 ones. Its octal representation is &O24, because 2 eights and 4 ones add up to 20. Similarly, &H4 = 4 = &O4, &HB = 11 = &O13, and &HF = 15 = &O17.
The following table shows some additional examples of the same numbers in decimal, octal, and hexadecimal.
Decimal
Octal
Hexadecimal
9
&O11
&H9
16
&O20
&H10
255
&O377
&HFF
In mrScriptBasic, if you try to use a hexadecimal value of, for example, F without preceding it with the &H prefix, you get a parsing error, because F is not a valid way of expressing a number. To express a hexadecimal number in mrScriptBasic, it has to start with &H, followed by the hexadecimal digits, in this case &HF. By itself, F is assumed to be the name of a variable.
See also
General information