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
-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.

How about you show some work first or your not gonna get very far here.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.