This is an old revision of the document!

A number in newRPL is represented as exact or approximate. To enter a number as approximate use a trailing dot. To enter a number as exact omit any trailing dot. For routine arithmetic this distinction doesn't matter much, but it does come into play when evaluating symbolic expressions.

Here are some examples:

Approximate Numbers Exact Numbers
1. 1
1.007. 1.007
1.007.e-10 1.007e-10

Arithmetic performed on numbers takes into account the operands (exact or approximate) and results are displayed accordingly.

For example, 1 3 / results in 0.333. (approximate), whereas 1 2 / results in 0.5 (exact).

Numbers in different bases can be entered by preceeding the value with a # and a trailing letter to indicate the base (b = binary, o = octal, d = decimal, h = hex, note that the trailing letter is case insensitive). Arithmetic can be done on numbers in different bases with the result displayed as the base of the first argument. Only exact numbers in the range $-2^{63}$ to $2^{63}-1$ can be expressed in multiple bases. Outside this range (or approximate numbers) will be switched to decimal.

Here are example arithmetic operations in bases other than 10:

#1101b #FFh + yields 100001100b

256 #FFFFh + yields 65,791

#355o #11010101b x yields #142461o

#7h 2 / yields 3.5

#2h 63 Y^X yields 9.223372E18

Command Function Example
BADDAdd#11001b #100000b BADD yields #111001b
BSUBSubtract #11001b #100000b BSUB yields -#111b
BMULMultiply #11001b #100000b BMUL yields #1100100000b
BDIVDivide #11001b #100000b BDIV yields 0.781
BANDLogical AND #1101010b #1100010b BAND yields #1100010b
BORLogical OR #1101010b #1100010b BOR yields #1101010b
BXORLogical XOR #1101010b #1100010b BXOR yields #1000b

Note that BMUL and BDIV can be used to left shift and right shift numbers (respectively) when the second operand is a power of 2.

The word size, applicable to exact numbers in other bases, can be set using the command STWS (STore Word Size). Valid ranges are 1 to 63 (not including the sign bit). So, for example, to work with 32 bit signed numbers, set the word size to 31. To view the currently set word size, use RCWS (ReCall Word Size). Note that setting too small a word size can lead to “rolling the register” and hence unexpected results, such as this:


120 4 BMUL


The result is -32, not the result of 480 as expected with a larger word size.

  • manual/chapter3/reals.1497577800.txt.gz
  • Last modified: 2017/06/15 18:50
  • by smartin