base
Full Description
swirl
Syntax
  string-expression base numeric-expression. 


Purpose

Used to convert a string representation of a non-decimal number into a numeric value.

The first operand in the syntax is a string representation of the number in the specified base (octal, hexidecimal, etc.). Letters (either uppercase or lowercase) are used to represent digits higher than 9. For instance, hexidecimal (base 16) numbers consist of the digits "0123456789abcde". Octal numbers (base 8) consist only of "01234567".

The second operand in the syntax is the radix, which must be between 2 and 36, inclusive.

If a character in the string expression is not a valid digit in the specified base, an error occurs. For example, the expression "16a" BASE 10 would cause an error, because "a" is not a valid digit in the base 10 system.

The following code illustrates the use of the base operator in converting a string represenation of a non-decimal number (ie, a number that is not in base 10) into a decimal numeric value. Note that hexidecimal numbers can contain the digits and letters "01234567890abcdef". When the letters are used, they can be either uppercase or lowercase.

  find [digit | "ABCDEFabcdef"]+ => hex-location
     local counter location
     set location to hex-location base 16

Copyright © OmniMark Technologies Corporation, 1988-1998.