This section contains a number of detailed examples illustrating how various types of radix conversion operations can be performed by the 101 instruction. For a specification of the 101 instruction and the notation used see section 3.10.
If a number, when converted, can be represented byeight characters or fewer, it can usually be converted by a single 101instruction, provided that the radices are all integers.
Example 1
If the number in A1 is a binary integer in the range 9999999 ≤ (A1)_{I }≤ 99999999 (10^{7}+1 ≤ (A1)_{I} ≤ 10^{8}1) it can be converted to characters by
101 CHARS RAD A1
with the program constants
RAD) +100000000
10,10,10,10,10,10,10,10+16
the +16 in the last radixcharacter ensuring that
zero is converted as 0.
Example 2
If (A1)_{I} represents pence of a sterling quantity in the range £99.19.11 to £999.19.11 inclusive, then it may be converted to characters with minussign if negative, and with full stops between pounds, shillings and pence by
101 CHARS STERL A1
with
STERL) +240000
10,10,10+16,1+32,2,10,1+32,12
This will convert a zero in the 10/ column as SP; to convert it as 0 the 5th radix should be 2+16.
Note that in these two examples, y is the product of the radices (i.e. y = ∏ r_{i}); this is true generally when converting an integer to eight or fewer characters. Note that it is not possible to use the 101function unless all radices are integral, e.g. to convert ounces to quarters, pounds and ounces would require radices such as 2.8 and 1.6 which cannot be produced.
A case in which y is not the product of the radices
is that of converting a binary fraction to
characters.
Example 3
If, in A1, is a nonnegative fraction, it may be converted for printing, to 6 decimal places preceded by 0. Thus:
51 A1 1
00 A1 RD
101 NUM CON A1
with
RD) +0.00000025
CON) 31,63,63,63,63,63,63,63
2+16,1+32,10,10,10,10,10,10
The word CON) is 0^{1}1^{47} = 1.02^{47}, i.e. it is the best singlelength approximation to +1.0 attainable. (A1) is shifted down 1 place to prevent the possibility of overflow (a) on adding the rounding constant which is in RD) and (b) on dividing by 1.02^{47.} This shift is compensated by giving the first radix r_{0} the value 2. This first radix forces a zero which is converted as 0 (because +16). The second radix (l) also forces a zero which is converted as fullstop (or decimal point). Thereafter, the digits proper are produced. Note that since the 0 produced by the radix character 2+16 is treated as significant, β being set, therefore any lefthand zeros in the fraction will be converted as numeral 0 and not as SP.
If the converted form has more than 8 characters, a
single 101instruction is not sufficient.
Example 4
Assuming that A1 contains any singlelength integer, convert it for output.
FIRST) 
14 
NUM 
0 

 Clear NUM 

101 
NUM+1 
CON 
A1 
 Convert l.s. 8 bits 

66 
FIN 
4 

 Test OVR, if clear, FIN 

40 
A1 
CON 

 if (A1) ≥ 10 

65 
SEC 
A1 

 Jump if quotient ≥ 0 

60 
SEC 
A2 

 Jump if remainder = 0 

81 
SEC 
A1 

 if <0, add 1 & test if ≠ 

14 
NUM 
30 

 if =0, put minus sign in NUM 

75 
... 
0 

 and exit 
CON) 
+100000000 



10,10,10,10,10,10,10,10+16 


SEC) 
101 
NUM 
CON 
A1 
 convert m.s. 7 digits 
FIN) 
75 
... 
0 

 and exit 
The first 101instruction produces the l.s. 8 digits in NUM+1. If the number occupies more than eight characters OVR is set, β is set and θ left clear. OVR is tested and left clear by the 66instruction; if the number occupies 8 characters or fewer, OVR is clear, the conversion is completed by the one 101instruction and so the 66instruction causes a jump to the exit point. Otherwise the number is divided by 10^{8}. The quotient in A1 corresponds to the m.s. digits and the remainder in A2 to the l.s. 8 digits.
If this quotient is nonnegative, it can be converted directly by a second 101instruction: the 65instructicn tests for this case. If the quotient is negative, it may be that all the l.s. 8 characters are zeros (i.e. the number is an integral multiple of 10). If so, the m.s. characters can be directly converted by a second 101instruction. This case will be indicated by a zero remainder on division by 10, which is detected by the 60instruction.
The 81instruction is obeyed if the integer is
negative and converts to more than 8 characters, i.e. N
≤
10^{8}. Suppose in fact, N=(10^{8}a+b) where a and b are
integers. Then when N is divided by 10^{8} (in the 40instruction) the
quotient will be (a+1) and the remainder 10^{8}b. The digits of b
have been correctly converted by the first 101instruction and thus it is
necessary to add 1 to the quotient and convert the result. In fact if, on
adding 1 to the quotient, the result is zero, it follows that OVR was set only
because b has eight digits and the minus sign could not be inserted into NUM+1.
In such a case the 81instruction does not cause a jump, the minus sign
character is put in the l.s. end of NUM and the sequence left. Otherwise a
second 101instruction is obeyed, converting the m.s. digits and inserting the
minus sign automatically.
Example 5
To convert a sterling quantity in the range
£9,999,999,999.19.11 to £99,999,999,999.19.11 inclusive, held as pence in A1.

14 
NUM 
0 


101 
NUM+1 
CON 
A1 

66 
FIN 
4 


40 
A1 
CON 


65 
SEC 
A1 


60 
SEC 
A2 


10 
A1 
1 


61 
SEC 
A1 


14 
NUM 
30 


75 
... 
0 

CON) 
+240000 




10,10,10+16,1+32,2,10,1+32,12 


+100000000 




10,10,10,10,10,10,10,10 

SEC) 
101 
NUM 
CON+2 
A1 
FIN) 
75 
... 
0 

The reasoning behind this sequence of instructions is
similar to that for Example 4. Note that the 81instruction of Example 4
is'replaced here by a 10instruction and a 61instruction. This is because, if
a sterling quantity in the given range is divided by 240000 the quotient may
exceed 24 bits and thus cannot be tested completely by an 81instruction.
Example 6
Given a signed fraction P in A1 , convert it to 13 decimal places, preceded by SP0. if positive or by 0. if negative, allowing also for the case of 1.0000000000000

14 
A3 
0 

 Clear A3 

65 
EB 
A1 

 Test if F ≥ 0 

66 
BB 
10 
A1 
 If < 0, test if F=1.0 

12 
A1 
0 

 If ≠ 1.0, negate fraction 

115 
A3 
30 

 and put minussign in A3 
BB) 
32 
A1 
CON+4 

 Multiply F by 10^{5} 

31 
A2 
CON+2 

 Multiply l.s. half by 10^{8}, rounded 

61 
CC 
CON+2 
A2 
 Test if latter product = 10^{8} 

10 
A1 
1 

 If so, add 1 to m.s.digits 

14 
A2 
0 

 and clear l.s.digits 
CC) 
101 
NUM 
CON 
A1 
 Convert m.s.digits 

101 
NUM 
CON+2 
A2 
 Convert l.s.digits 

00 
NUM 
A3 

 Add sign if F negative 

75 
.... 
O 

 Exit 
CON) 
+200000 



1,2+16,1+32,10,10,10,10,10 


+100000000 



10+16,10,10,10,10,10,10,10 


+100000 
In this method of solution the two multiplication instructions are used to transform the fraction into two integers, that in A1 representing the five m.s. decimal places and that in A2 representing the l.s. eight decimal places. The first radix, 1, in CON+1 serves to force a zero, converted as SP in which the minus sign may be set when appropriate.