(12C) Check if two numbers is to the power of other
|
09-09-2018, 04:24 PM
(This post was last modified: 09-09-2018 05:11 PM by Dieter.)
Post: #18
|
|||
|
|||
RE: (12C) Check if two numbers is to the power of other
(09-06-2018 07:07 PM)stored Wrote: Perhaps it is more practical to use logarithmic formula: Since the 12CP emulator has roundoff errors anyway, maybe the following approach will work, both on an original 12C and the mis-behaving emulator. The idea is: round the result of ln(n2)/ln(n1) to the nearest integer, then calculate n1^this and check if the result matches n2. As far as I got it, even the 12CP emulator returns powers correctly when rounded to 10 digits. So this should work: Code: 01 f 9 Maybe someone can try this. The program sets and exits with FIX 9 mode. If you want to reset this to FIX 2 (or anything else) insert the respective command after the RND in line 20 and before the X=0? test that follows. EDIT: Here's an even better version. It returns additional information even if n2 is not an integer power of n1. The stack then holds the closest approximation. Try it and see what you get, e.g. for 5 and 600. Code: 01 f 9 5 [ENTER] 600 [R/S] => 0 [R↓] 5 [R↓] 4 [R↓] 625 2 [ENTER] 512 [R/S] => 1 [R↓] 2 [R↓] 9 [R↓] 512 Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)