Post Reply 
HP Prime CAS & Large numbers
09-27-2023, 05:18 PM
Post: #11
RE: HP Prime CAS & Large numbers
(09-08-2022 09:14 AM)Mario Blasone Wrote:  I tried to find the largest integer number that the Prime can manage in CAS.
I guess CAS integer are internally formatted in binary, so I empirically searched the largest power of 2 before the Prime returns "undefined": it is 2^8598.
I guess that the largest integer is (mathematically) 2^8599-1, but you can't write this expression on Prima without getting "undefined".
I tried this: Σ(2^n,n,0,8598).
It returns an integer with 2588 digits that (I think) is the largest integer before getting "undefined"; you can verify this adding just 1 to it and the result is "undefined".
format(Σ(2^n,n,0,8598),"d10") -> "3.605227827e+2588"
Similarly I searched the smallest (most negative) integer, finding it to be Σ(-2^n,n,0,8597). if you try to subtract just 1 to it, you get "undefined".
The question now is: why such particular number of bits (8599) has been chosen for the binary format of integer in CAS?
Other "odds":
- format(Σ(-2^n,n,0,8597),"d10") -> ""; why?
- format(Σ(2^n,n,0,8598),"a12") -> "3.605227827e+2588"; not in hexadecimal form; why?
- format(Σ(2^n,n,0,29),"a12") -> "0x1.fffffff80000p+29"; OK, but...
- format(Σ(2^n,n,0,29),"h12") -> "1073741823"
Note that "a12 (or "h12") shows the max number of fractional digit in the hexadecimal format; such that from "a13" to "a99" you get the same result.
- format(Σ(2^n,n,0,30),"a12") -> "2147483647"; not formatted; why?
- format(999999999999,"a12") -> "999999999999"
- format(999999999999+1,"h12") -> "1.00000000000e+12"
- format(Σ(2^n,n,0,29)*2+1,"a12") -> "0x1.fffffffc0000p+30"
- format(Σ(2^n,n,0,29)*2+2,"a12") -> "2147483648"

Concerning "odds" with 'format' command:
I guess that format(obj,"a12") initially converts obj to float and then put the result in the hex format.
The maximum integer n that may be used in approx(n), before getting +inf, is largely smaller than max_integer.
After several trials I obtained that such max n is Sum(2^(n-1),1,1023); i.e. binary integers with 1024 bits (including sign).
approx(Σ(2^(n-1),n,1,1023))=8.98846567431e307
approx(Σ(2^(n-1),n,1,1023)+1)=+inf
approx(Σ(-2^(n-1),n,1,1023))=−8.98846567431e307
approx(Σ(-2^(n-1),n,1,1023)-1)=+inf (Not -inf; this is really odd!!)

format(n,"a8") shows the value of approx(n) in hex format for n≤(2*Σ(2^(n-1),n,1,30)+1), that is mathematically equivalent (2^31-1), without triggering the internal limit on"a8" format
format(2*Σ(2^(n-1),n,1,30)+1,"a8")="0x1.fffffffcp+30".
But format(2^31-1,"a8")="2.1474836e+9"
Note that the above fractional part (ff ff ff fc)_base16 corresponds to 30 consecutive binary ones (7 Bytes and half, or 15 nibles, or 7*4+2=30 bits, all at binary 1).
format(2*Σ(2^(n-1),n,1,30)+2"a8")="2.1474836e+9" (it reverts to "s8" scientific notation).
Hexadecimal formats longer than "a8" ("a9" and onward) add only non significant zeros after 8-th hex fractional digit.
format(π,"d16")="3.141592653589782" saturates the number of fractional digits (from "a17" onward produces the same result).
format(n/m,"a8") for small rationals a/b (as 1/(2^n) ) seems not having the same limitation.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP Prime CAS & Large numbers - Bipman - 08-10-2017, 08:27 AM
RE: HP Prime CAS & Large numbers - Arno K - 08-10-2017, 11:35 AM
RE: HP Prime CAS & Large numbers - Bipman - 08-10-2017, 11:39 AM
RE: HP Prime CAS & Large numbers - Bipman - 08-10-2017, 02:03 PM
RE: HP Prime CAS & Large numbers - Bipman - 08-13-2017, 09:11 AM
RE: HP Prime CAS & Large numbers - Mario Blasone - 09-27-2023 05:18 PM
RE: HP Prime CAS & Large numbers - parisse - 09-27-2023, 06:37 PM
RE: HP Prime CAS & Large numbers - parisse - 09-29-2023, 10:46 AM



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