Post Reply 
All decimal digits of reals in CAS
04-12-2015, 03:15 AM (This post was last modified: 04-12-2015 03:21 AM by Joe Horn.)
Post: #6
RE: "dec": All decimal digits of reals in CAS
(04-11-2015 02:43 AM)compsystems Wrote:  dec(e) => "2.7182818284590410939927096478641033172607421875"
dec(√(2)) "1.4142135623730922588947578333318233489990234375"
always returns ~50 digits

Joe Horn, please add at the beginning of your code, check flag should be in exact mode, otherwise always returns until 50 digits

There seems to be a misunderstanding here. The "dec" program does not return "about 50 digits". It always returns ALL the digits, no matter how many that may be. The reason that dec(e) returns "2.7182818284590410939927096478641033172607421875" is because that decimal number is EXACTLY how Prime stores e internally in CAS. It's not an approximation.* "dec" returns the exact decimal of the real input, no matter how many decimal digits that may require. It doesn't arbitrarily stop after 50 digits, or any other number of digits. (Exception: if the input is a ratio of two integer-type objects, "dec" stops after outputting 1000 digits, as explained in the original posting).

Other ways of seeing exactly the same value using my other routines:

hex(e) --> "1.5BF0A8B14576p+1"
d2f(e) --> 191282078589627/2^46

* Ok, ok, to be perfectly clear: it IS an approximation of the math constant e... but it's not an approximation of CAS's real floating-point value of e. It's exactly equal to THAT value, which is itself a rational approximation of the irrational constant known as "e".

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: "dec": All decimal digits of reals in CAS - Joe Horn - 04-12-2015 03:15 AM



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