Dismal Arithmetic & 3 Progs for 49G & Others - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Dismal Arithmetic & 3 Progs for 49G & Others (/thread-3690.html) Pages: 1 2 |
RE: Dismal Arithmetic & 2 Progs for 49G, the Prime, 48S & 32S & TI & C... - Dave Britten - 05-11-2015 04:16 PM Now for something in BASIC: the Casio fx-702p "programmable calculator" (really more of a pocket computer). This is the slowest one yet, at 1:44 to do 435,821 * 2,949,229, but it DOES yield the full-precision result, 244,585,835,821, unlike the Casio graphing calculator. It displays 2.445858358E11, but you can pry the other digits out by executing F-2.445E11. Just run it, tell it if you want to "A"dd, or "M"ultiply, then enter your two inputs. Code: 1 INP "(A)DD (M)ULT:",$ Notes: I think this is one of Casio's first BASIC machines, so it's got a few odd limitations. A number of keywords are abbreviated from what's typically used (PRT, INP, GSB, RET, etc). Variable naming and availability are limited much like the Sharp pocket computers. Single-character names, and some basic array functionality. Variables can hold numbers or strings (e.g. A vs. A$), but are limited to 7-character strings. The dedicated string variable, named simply $, can hold 30 characters. There are two forms of the IF statement. This will do a GOTO if true: IF X>3 THEN 90 And this will skip the rest of the line if false: IF X>3;F=7:GSB 300 Note that you have to terminate the IF with a semicolon, whereas you use a colon to separate the rest of the statements. The IF statement can't evaluate any compound expressions; there's no AND or OR functions! But you can string conditions together into a simple AND chain like this: IF X>3;IF J<10;GSB 500:RET Anything more complicated, and you're going to be doing GOTO stunts. There's no DATA or READ statements. Not an issue here, but it was an annoying discovery when I was porting the usual prime factors program. It's sloooow. It took almost 5 times as long as running the same algorithm on the Casio fx-8500g. Despite all that, I like it, largely because it has slots for 10 independent programs, like most Casios do. The Sharp and TI offerings typically only provide a single program space. RE: Dismal Arithmetic & 2 Progs for 49G, the Prime, 48S & 32S & TI & C... - Marcus von Cube - 05-11-2015 06:04 PM For additional info about pocket computer BASIC dialects I recommend looking at my BASIC Comparison Sheet. RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 05-13-2015 09:19 AM Given DPLUS & DMULT prompts the question: What does DPOW do? As repeated addition of n to n produces n, this possibility is discarded as being too dull even for dismals. Conservatively, repeated multiplication looks like a promising candidate. Here again, single digit powering is of little interest, as eg 5 d^ 300000001 = 5 but for integers > 9 the results become interesting - hopefully not so interesting that the operation is not regarded as dismal. So here's a provisional programme using the provisional definition of Dpowering - I name the programme DPOW. Enter positive integer n to power to positive integer power p, eg 123 4 produces 111122223. DPOW Code: :: Alternative definitions of Dpowering welcome, programmes too. RE: Dismal Arithmetic & 3 Progs for 49G & Others - Dave Britten - 05-13-2015 05:59 PM Damn it, Gerald, you're just trying to get me to rewrite all those goofy ports I did. ;D Actually, this would be pretty simple to add to any of the existing programs. You just need to store another loop counter, a copy of the original base, and depending on the language, a running total, then just stick in an outer loop that calls the multiply routine repeatedly. Part of me says, yeah, that's a sensible definition of powering, since it maintains x^2 = x*x, but for these operations, x+x != 2*x. So I guess it could reasonably go either way, really. RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 05-13-2015 06:37 PM With my definition & my programme 123 d^ 30 takes 11.6 sec on the 50G, so simply multiplying n times will take a truly dismally long time. RE: Dismal Arithmetic & 3 Progs for 49G & Others - Dave Britten - 05-13-2015 07:26 PM (05-13-2015 06:37 PM)Gerald H Wrote: With my definition & my programme 123 d^ 30 takes 11.6 sec on the 50G, so simply multiplying n times will take a truly dismally long time. True. We're probably looking at something like O(n log n) complexity for this. Good reason not to try it on my TI-66. RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 10-28-2015 02:17 PM Two programmes for the HP 35S, a translation of Dave Britten's 32S programmes above. Given stack levels X & Y integers, programme A returns dismal sum & programme M returns dismal product. Code:
RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 10-30-2015 10:43 AM Here a copy of Dave Britten's programmes for the HP 42S. DIS+ performs dismal addition, DIS* dismal multiplication. Code:
|