Post Reply 
Greater than 32bit binary conversion.
05-14-2022, 02:17 PM
Post: #1
Greater than 32bit binary conversion.
I want to convert any binary number of lets say less than 512 bit, to a base 20 integer.

Is there a way to do that with some built in features of the calculator as is, or does it need a program?

I have written a little program anyway, that will take in any length of a binary number in string format, but I do not know how to convert it to a number that can retain a large amount of digits. Is there a CAS command or function that will allow that?

Code:
EXPORT B2D(A)
BEGIN 
 // LOCAL A:="";
LOCAL B:=0;
 // INPUT({{A,[2]}});
     FOR X FROM 1 TO size(A) DO
        IF expr(A(size(A)-(X-1),1)) THEN 
          B:=B+2^(X-1);
        END;
     END;
  B;
END;

If you run this as : B2D("10110110110"), then it will return 1,426. But if you enter a larger binary number, then the amount of digits will get truncated to 12 with an E45, for example, at the end, and therefore numbers will be lost. I would like the number output (or string I suppose) to be as large as it has to be, to house every piece of information that the binary number contained. It would be best if it was a number form, so that it could then be further manipulated.

Is there a was to force CAS level number sizes, and accuracy of upwards of 90 base 10 digits?
Find all posts by this user
Quote this message in a reply
05-15-2022, 05:43 AM
Post: #2
RE: Greater than 32bit binary conversion.
In CAS, type 0b10110110110
Find all posts by this user
Quote this message in a reply
05-15-2022, 01:05 PM
Post: #3
RE: Greater than 32bit binary conversion.
That's great.

Is there a way to achieve CAS length numbers from a program?
Find all posts by this user
Quote this message in a reply
05-15-2022, 01:44 PM
Post: #4
RE: Greater than 32bit binary conversion.
(05-15-2022 01:05 PM)matalog Wrote:  That's great.

Is there a way to achieve CAS length numbers from a program?


Something like this?
long() run from the cas screen will return 70368684086562

Code:

#cas
long():=
BEGIN
0b001111111111111111111100011010110001010100100010;
END
#end
Find all posts by this user
Quote this message in a reply
Post Reply 




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