Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dawnraid

macrumors regular
Original poster
Nov 9, 2007
161
0
Hi,
I have been given a problem as part of an assignment for college,
I cant contact any of the tutors at the moment as we are on holiday.
So I was just wondering If I could get some help on here.
The Question is
Convert 1111.0011 (this is base 2) to octal, hexidecimal and decimal. Assume unsigned arithmetic representation only.
Now I know you guys dont like doing peoples homework for them. so dont post the answers. I just need your help understanding why there is a ".' in between the original binary string, does this mean the value is a fraction in which case its decimal representation is 15.3 . If so how would I show this in octal/hex notation would I put a "." in the answer. Some explanation would be a great help.

Thanks.
 
The binary point means there is a fractional component. It is not 3. It is 3/16. In decimal this is .1875. Each place after the binary/hexadecimal/octal point has a value of z*1/(x^n) where n is the number of positions to the right of the point and x is the base you're working in, and z is the quantity at that position.

1111.0011 binary
F.3 hex
17.14 octal
15.1875 decimal

binary to hex and binary to octal is super easy. Every 3 bits is one octet, every 4 bits is one hexit. Decimal is the real pain in the ass.

-Lee
 
Decimal is the real pain in the ass.

Now that is a bit harsh. In a high-level language, it should be as simple as a series of shift-and-add operations (switching the shift/add order at the fraction point), then relying on printf to format the result. In AL, I seem to recall doing it (on an int) with modulus, though I never got to futzing with fractions.
 
Now that is a bit harsh. In a high-level language, it should be as simple as a series of shift-and-add operations (switching the shift/add order at the fraction point), then relying on printf to format the result. In AL, I seem to recall doing it (on an int) with modulus, though I never got to futzing with fractions.

It's basic arithmetic.

3/16 = .1875

.1875 = 1875 / 10000

3 * 10000 / 16 = 1875
 
It's basic arithmetic.

3/16 = .1875

.1875 = 1875 / 10000

3 * 10000 / 16 = 1875

In front of you, that is fine. I was speaking of many years ago when I wrote a simple integer calculator on a 6502 Commodore in AL. Converting binary integers into their decimal string was a simple matter of using modulus from right to left - creating a decimal representation of a binary fraction is a little more challenging at that level (meaning, essentially with no system tools unless you want to dive into calling the BASIC routines in ROM).
 
Hi im curious as to how you got the 17.14 as the octal?
Where abouts did you pad / split the string?
I split it like this 001| 111 | 000 | 011.

Which results in 17.03
Im new to all of this so my way probably isnt right.
 
Edit: My bad just figured it out pad to 00 to the front and back and split.
Cheers guys, you have been a big help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.