Re: RPN Programming exercise (HP-42S) - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Re: RPN Programming exercise (HP-42S) (/thread-212752.html) |
Re: RPN Programming exercise (HP-42S) - Gerson W. Barbosa - 02-27-2012 Thanks all of you for your participation and interesting solutions. Most of them supersede mine, as they are shorter, faster and accept a wider range of operands, exactly what I expected them to be. Here are my solutions:
00 { 77-Byte Prgm }This will accept two numbers in the range [1000..9999] and give their product.
Examples: 1234 ENTER 5678 XEQ MLTA --> 7,006,652Here is an equivalent QBASIC program: CLS
The next program is an implementation of the Russian Peasant Multiplication Method: 00 { 52-Byte Prgm }
This will give the product of any two positive integer numbers, as long as the result doesn't exceed 236-1. 12 ENTER 3456789 XEQ MLTB --> 41,481,468 Here is a variation of the first program, in case one of the operands is allowed to be entered as two separate two-digit numbers, as proposed somewhere else in this thread:
00 { 47-Byte Prgm }
Examples: 12 ENTER 34 ENTER 5678 XEQ MLTC --> 7,006,652 Gerson.
P.S.: Programs #1 and #3 require the allocation of 100 numbered registers: Shift MODES \/ SIZE 0100
Edited: 27 Feb 2012, 5:39 p.m.
Re: RPN Programming exercise (HP-42S) - Marcus von Cube, Germany - 02-27-2012 I was missing AIP. Used instead of ARCL it would have saved the problems with the 1000s separator or the decimal point. Otherwise, my program wouldn't need big changes.
|