Division in CAS - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Division in CAS (/thread-18387.html) |
Division in CAS - matalog - 05-18-2022 05:52 PM I was writing a long integer divider program, and was testing a value to see if it was working, and it was right, but it looks like the Prime was wrong, in CAS. I know this is very unlikely, and I hope someone will explain that it is down to the limited amount of information stored about the number, resulting in the wrong number being displayed after the place where E was. I calculated 123456789123456789/127, in CAS mode. It gave the result 123456789123456789/127, then I pressed a b/c and it gave 9.72100701759E14 and I then pressed a b/c again, which resulted in the value that is not correct, which is 972100701759492. I have just tried another 147258369147258369/127 and pressing a b/c twice again results in 1159514717694936, which is wrong by 11! The answer could have been as accurate as 1159514717694947.7874015748031496062992125984251968503937007874015748031496062992125984251968503937007874015748031496. Is there any way to get full length division results in CAS, just like the long results from multiplication? Or a way to get more accurate results from CAS? RE: Division in CAS - Nigel (UK) - 05-18-2022 08:41 PM You can use the iquo() CAS function to get an exact integer result for a quotient of two integers. There is also a function irem() that gives the remainder. Nigel (UK) RE: Division in CAS - Albert Chan - 05-18-2022 09:37 PM [a b/c] key turning exact fraction to approximation may be a bug. (if exact mode is ON) Number once turned approximate, may not be able to revert back to exact form. exact() does not really mean "exact", only rationalize the approximated number CAS> exact(approx(π)) → 4272943/1360120 Also, in CAS, approx numbers shown may not match what is internally stored. CAS> approx(123456789123456789/127) → 9.72100701759e14 CAS> Ans-9.72100701759e14 → 492. 972100701759492 is stored as hex-float 0x1.ba0f6a81d4020p+49 |