FANDOM


A number may be expressed in hexadecimal form in SmileBasic by using the prefix &H.  For a numeric literal, &h is converted to &H, and lowercase digits a to f are converted to uppercase A to F, so for example PRINT &hBa gives 186, but PRINT VAL("&hBa") gives Syntax error (VAL), and PRINT VAL("&HBa") gives 11.  Another difference between the way &H is handled in literals and in VAL is that VAL does not require any digits to follow: PRINT &H makes a Syntax error, but PRINT VAL("&H") gives 0.

If more than 5 hexadecimal digits follow the prefix in a literal, the system will generate a Syntax error, even if the first digits are 0 and the value is within SmileBasic's range.  If more than 5 hexadecimal digits follow the prefix in a string passed to VAL, the system instead generates an Overflow (VAL) error, again even if the value is within SmileBasic's range.  The values &H80000 to &HFFFFF give negative numbers in the standard 2s complement sense, and &H80000 in particular is a value which exposes some bugs in SmileBasic.

For some operators, it is not necessary to put a space between the end of the literal and the operator, e.g. PRINT &HA+&HB will give 21 as expected, but for others, it is necessary, e.g. PRINT &HAOR&HC gives the confusing result 10012, and the assignment V=&HAOR&HC generates a Syntax Error.  The commands PRINT &HA OR&HC and V=&HA OR&HC will give the expected results.

The prefix for binary values is &B.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.