Post Reply 
Decimal to binary in HP Prime
04-16-2019, 05:02 PM
Post: #1
Decimal to binary in HP Prime
How to perform the conversion of a number such as 3.2672 decimal to binary in Hp Prime?

Leo

Visit this user's website Find all posts by this user
Quote this message in a reply
04-16-2019, 07:16 PM
Post: #2
RE: Decimal to binary in HP Prime
R->B() will convert an integer to binary - if your base is set to 2.

I don't know that it can convert floating point.
Find all posts by this user
Quote this message in a reply
04-16-2019, 10:27 PM (This post was last modified: 04-18-2019 12:00 AM by Albert Chan.)
Post: #3
RE: Decimal to binary in HP Prime
I try this in XCas:

bits(x) := convert(convert(trunc(x),base,2),base,10)

x = exact(3.2672) -> 2042/625

bits(x * 2^22) -> 110100010001100111001110

3.2672 ~ 0b11.0100010001100111001110 (24 bits)

For *exact* conversion, we need to get number of repeated bits:

order(a,n) := {local k=0, t=1 mod n; repeat t*=a; k++ until t=1; k}

Since denominator is odd, we can get repeated bits = order(2,625) = 500

bits(x * 2^500), we got:

x = 0b11.(
01000100011001110011100000011101011111011011111101
00100001111111110010111001001000111010001010011100
01110111100110100110101101010000101100001111001001
11101110110010111111101100010101101101010111001111
10101010110011011001111010000011111001000010010110
10111011100110001100011111100010100000100100000010
11011110000000001101000110110111000101110101100011
10001000011001011001010010101111010011110000110110
00010001001101000000010011101010010010101000110000
01010101001100100110000101111100000110111101101001)
Find all posts by this user
Quote this message in a reply
Post Reply 




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