# Binary Code conversion - Doubts

#### crisstark

Joined Sep 17, 2017
1
Hi guys, I'm new here! I saw your website and I found a lot of useful didactic material. I'm attending electronic Engineering and I can't understand how to do this kind of exercises for my "Foundations of Informatics" exam.
This is one of them:
Given two numbers (one positive and one negative) and using the least number of digits needed (I have to write this number for each conversion) I have to convert these numbers in:

- Absolute value base 2

- Absolute value base 16

- One's complement

-Two's complement

- Sixteen's complement

- BCD code

- Excess Notation where the polarization is 2^n-1 -1 (n stands for the least number of digits needed).

For example I have the following numbers -256 , 217, 754.

Thanks a lot for your time!

#### Papabravo

Joined Feb 24, 2006
12,878
Let's take 754. How many bits (binary digits) will you need? Most folks here will know the answer without computing it. Do you?

I prefer:
$$log_2(754)=\left\lfloor \frac{log_{10}(754)}{log_{10}(2)} + 1 \right\rfloor= \text ?$$

Last edited:

#### WBahn

Joined Mar 31, 2012
25,222
You said given two numbers, one positive and one negative. But you were given three. Are these three different problems with each one using one of those numbers along with its additive inverse? Or do you just need to choose a number of digits that can represent all three numbers in each representation?

By "absolute value" does these mean that you dedicate one digit to being a sign digit and then use the other digits for the absolute value of the number? I've never heard it called this -- I've usually heard it referred to as sign/magnitude, but absolute value makes sense as an alternate name.

The first thing you need to do is be sure that you understand all seven representations and what the range of values that can be represented for N digits.