COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### [49] decimal to binary conversion

• Follow

How would you convert 23.57 to binary on a HP49?

The calc rounds up 24 in this case before converting.  It rounds down other
cases.

As a home work assignment, it converts to 10111.1001.

danny

 0
Reply dmathews 9/1/2003 12:04:51 AM

In article <D2w4b.237912\$cF.77191@rwcrnsc53>, spam357@attbi.com says...
> How would you convert 23.57 to binary on a HP49?
>
> The calc rounds up 24 in this case before converting.  It rounds down other
> cases.
>
> As a home work assignment, it converts to 10111.1001.
>
> danny

The "hex strings" on the HP 49G, which can be displayed in either base 2,
8, 10, or 16, can only be integers, with no fractional part whatsoever.
Thus, when you use the command R->B with 23.57, the calculator does the
best it can to make the number an integer:  it rounds.

To do base conversion with fractional parts to your numbers, you will
need additional software.  There is a program called Mawk, which has many
string manipulation utilities, with a number base converter in there too.
However, a program called Bconv does a good job, and it does not have the
other stuff, which you do not need.  It works for number bases from 2 to
36.  I am not too confident in either one of them, though.  See the
following link for Bconv:

http://www.hpcalc.org/details.php?id=5161
 0
Reply Sam 9/1/2003 1:55:34 AM

Precision to the right of the radix is a sticky question, so
most base conversion schemes stick with something they can do
accurately -- that would be integers.

..57[10] is a little greater than .1001[2] and a little less
than .1001001[2] and a little bit (less) greater than
..10010001111[2]...   It's a question of how much fuzz you
can tolerate.

dmathews wrote:
> How would you convert 23.57 to binary on a HP49?
>
> The calc rounds up 24 in this case before converting.  It rounds down other
> cases.
>
> As a home work assignment, it converts to 10111.1001.
>
> danny
>
>

 0
Reply ais01479 9/1/2003 2:05:23 AM

In article <D2w4b.237912\$cF.77191@rwcrnsc53>,
"dmathews" <spam357@attbi.com> wrote:

> How would you convert 23.57 to binary on a HP49?
>
> The calc rounds up 24 in this case before converting.  It rounds down other
> cases.
>
> As a home work assignment, it converts to 10111.1001.
>
> danny

As the calc only converts integers, you can multiply by some power of 2:
here, you want for digits (probabliy not the right word for binary...)
after the dot, so you can multiply by 2^4 :

23.57 * 2^4 = 377.12
377.12   R->B   #101111001b
So your result is 10111.1001, once you've divided by 2^4.
Of course, this is not an exact calculation.

Camille
 0
Reply Camille 9/1/2003 5:53:01 AM

"dmathews" <spam357@attbi.com> wrote in message
news:D2w4b.237912\$cF.77191@rwcrnsc53...
> How would you convert 23.57 to binary on a HP49?
>
> The calc rounds up 24 in this case before converting.  It rounds down
> other cases.
>
> As a home work assignment, it converts to 10111.1001.
>
> danny

Camille brought up multiplying by 2^n before conversion, then dividing
by 2^n after.  I wondered how to get max accuracy using the calculator.
I think it is this:

What is the limiting tool, 12-digit floating point calculator precision
or 64-bit integers?  2^64 ~= 1.8E19 (about 19 decimal digits) so the
12-digit floating point calculator accuracy is the limit.  log2(10^12)
~= 39.9.  12 decimal digits correspond to about 40 bits.

23.57*2^35 = 809859033334
23.57*2^36 = <an exponential display, so don't use it>

64 STWS 809859033334 R->B produces #BC8F5C28F6h =

10111 10010001111010111000010100011110110

And counting on 23.57*2^35 being accurate to the final "4", this is
accurate to the last bit shown.  (It is, checked by other means.)

Rick

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 100,000 Newsgroups - 19 Different Servers! =-----
 0
Reply Rick 9/1/2003 4:20:26 PM

If I am not mistaken, in order to convert the fractional part of a
base ten number to binary you need to do the following:

Add the reciprocal of 2^x, (that is 2 to the power of x), where 'x' is
any whole positive integer from 1 to ?, until you have reached but not
excedded the number you are trying to represent, not adding those
values which will put you over the value of the number you are trying
to convert. As an example:

0.65625 = 1/2 + 1/8 + 1/32, (0.65625 equals the reciprocal of 2 plus
the reciprocal of 8 plus the reciprocal of 32).

It was not needed to add 1/4 or 1/16 or the reciprocal of any higher
number.

Therefore, your example, correctly converted, results in the following
binary number, which is 27 characters long, with the last character, a
1, being questionable. I will list the number divided into groups of
eight characters for readability purposes only, the number has no
spaces in it.

10010001 11101011 10000101 001

That is the number is the sum of the reciprocals of each of the
following:

2, 16, 256, 512, 1024, 2048, 8192, 32768, 65536, 131012, 4194304,
16777216 & 134217728, again the last character is questionable.

Adding up all the values results in a total of:

0.5700000003 which is 0.0000000003 larger than your original number.

It is quite possible then, and is in fact most likely to happen, that
many numbers will not have an exact conversion, although they may be a
finite number in base ten, that is to say not a repeating decimal.
Other numbers that are a repeating number will convert to a repeating
binary number.

As an example:

0.33333333333333......

converts to:

0101010101010101......

I hope you have found the above interesting and helpful.

rdb.
 0
Reply rdbzhch 9/1/2003 8:04:20 PM

"Rick Nungester" <nungester@mail.com> wrote in message
news:3f539644\$1_7@corp.newsgroups.com...
X
> You could keep pushing the "obvious versus non-obvious" bound
> and picking off fractional bits:
>
> 23.57 = 23.5 + 0.07
>       = 23.5 + 0.0625 + 0.0075
>       = 10111.1b + 0.0001b + 0.0075
>
> and convert 0.00075 to binary.  Anyone have a way to get more
> bits on an HP-48/49?  Any arbitrary-precision software known
> to do this type of thing?

Hi, Rick
I never though of this!
We already have Integers with memory limited precision.
We also have external software (Gjermund Skailart) to handle
Reals with DIGITS limited to arbitrary number (like 100.)
BUT
There is no "infinite" binary number library that also could handle
A) more than 64-bits, like integers
B) fractional part with Extended Presision (BITS limitation)
C) Works on any base from 2..36 oe at least BIN/OCT/DEC/HEX
VPN

 0
Reply Veli 9/2/2003 5:11:29 AM

6 Replies
651 Views

(page loaded in 0.124 seconds)

Similiar Articles:

7/23/2012 2:18:14 AM