All decimal digits of reals in CAS

04072015, 03:17 AM
(This post was last modified: 05292017 01:41 PM by Joe Horn.)
Post: #1




All decimal digits of reals in CAS
This program, called "dec", outputs the exact internal decimal value of a floating point number in CAS. It is similar to (and is based on) my "hex" program with the only difference being that the output of "dec" is in standard decimal format, instead of hexadecimal.
Syntax in CAS: dec(real) Output: exact decimal representation of the real in scientific notation. Example in CAS: dec(pi) > "3.1415926535897824578569270670413970947265625" This means that pi in CAS is internally stored as exactly the same value as the displayed decimal number. The value is actually stored in binary, of course, but sometimes seeing its decimal equivalent is helpful, so that's what "dec" was created to do. If the display modes allowed settings up to 50 digits, there would be no need for this program. Trivial bonus feature: If the input is a ratio of exact integers, "dec" attempts to return all the digits of the ratio, up to 1000 digits. I cannot imagine any possible use for this feature. Example: dec(1./1537) > "6.506180871828206591089838184416294097900390625E4" (notice the "." in the input) dec(1 /1537) > "6.50618087182823682498373454782042940793754066363044892648015614834...E4" (1000 digits) "dec", a CAS program: Code: #cas Interesting exploration: Compare dec(pi) with dec(pI) with "pi" and "pI" spelled exactly as shown. See the difference in the results? pI is CAS's name for Home's pi. Disclaimer: Extensive testing on extreme inputs and goofy inputs and illegal inputs has not been done. It'll probably choke on stupid inputs. Weeding them out is left as an exercise for the student. <0ΙΈ0> Joe 

« Next Oldest  Next Newest »

Messages In This Thread 
All decimal digits of reals in CAS  Joe Horn  04072015 03:17 AM
RE: "dec": All decimal digits of reals in CAS  compsystems  04102015, 02:55 PM
RE: "dec": All decimal digits of reals in CAS  Terje Vallestad  04102015, 08:14 PM
RE: "dec": All decimal digits of reals in CAS  Han  04102015, 09:02 PM
RE: "dec": All decimal digits of reals in CAS  compsystems  04112015, 02:43 AM
RE: "dec": All decimal digits of reals in CAS  Joe Horn  04122015, 03:15 AM
RE: "dec": All decimal digits of reals in CAS  Alberto Candel  11022016, 10:05 PM
RE: "dec": All decimal digits of reals in CAS  Joe Horn  11062016, 04:04 AM
RE: "dec": All decimal digits of reals in CAS  Alberto Candel  11062016, 05:44 AM
RE: "dec": All decimal digits of reals in CAS  Joe Horn  11072016, 04:16 AM
RE: "dec": All decimal digits of reals in CAS  Alberto Candel  11072016, 03:05 PM

User(s) browsing this thread: 1 Guest(s)