Average of A B
This layout calculates the average of two numbers. These are added and then shifted right to divide by 2. Two functions are used:
- Accumulator function, to add A to B.
- Shift Right function, to divide S by 2.
Operation
Enter the values of A and B and start the train from the station. When the train returns and halts, the average value can be read from register S.
|
Click layout to pause/run train | Click points to switch 0/1 | Click start circle to reset train/points |
Lazy points switch between upper 0 or lower 1 branch lines Trains arriving on a branch line switch the point to that line |
|
Sprung points allow branch line trains to join the main line All main line trains go straight ahead and never 'branch off' |
Notes
- If the sum of A and B exceeds 15 then an overflow error occours.
- The value of B is 'lost'.
- No need to clear S before a calculation as it is always over-written.
- The Shift Right function inserts leading 0's.