0

I am making a program that takes a binary number (a boolean array) and gives numerous representations.

For example, Enter binary (8 bits): 10001000
-Unsigned int: 136
-Hexadecimal: 88
-Octal: 210
-Two's complement: -120
-Sign magnitude: -8
-One's complement: -119
-Excess-127: 9
-ASCII: N/A
-Pep/8: SUBX immediate
-Floating-point: -0.125

I currently have all of the representations working, except floating-point. FP format would be 1 sign bit, 3 bit exponent (excess-3), and 4 bit significand. Does anyone have any suggestions on how to go about doing this? Thanks.

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by NicAx64
0

I can give you the idea , but writing that entire program is up's to you.

First think that I convert 10101 to decimal. Think in simple.
= 2^0 * 1 + 2^1 * 0 + 2^2 *1 + 2^3 * 0 + 2^4 * 1 .......

so you can hard-code this , or you can implement a for loop until
you finish up to input binary number length. Just right shift by one
means multiply by two.

So you can easilly get an unsigned int.
Then start using this , you can typecast it to other data representations.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.