How does one translate the following binary to Decimal. And yes the decimal points are with the whole binary value
1) 101.011
b) .111
Each 1 corresponds to a power of 2, the power used is based on the placement of the 1:
101.011
= 1*2^2 + 0*2^1 + 1*2^0 + 0*2^-1 + 1*2^-2 + 2*2^-3
= 1*4 + 1*1 + 1/4 + 1/8
= 5.375
.111
= 1*2^-1 + 1*2^-2 + 1*2^-3
= 1/2 + 1/4 + 1/8
= .875
If you don't like dealing with the decimal point you can always left shift by multiplying by a power of 2:
101.011 * 2^3 = 101011
Then convert that to decimal and, since you multiplied by 2^3 = 8, divide the result by 8 to get your answer. 101011 converts to 43 and 43/8 = 5.375.
1) 101.011
= 2*2^-3 + 1*2^-2 + 0*2^-1 + 1*2^0 + 0*2^1 + 1*2^2
= (1/8) + (1/4) + 0 + 1 + 0 + 4
= 5.375
2) .111
= 1*2^-3 + 1*2^-2 + 1*2^-1
= (1/8) + (1/4) + (1/2)
= .875
101.011 should be converted like below
(101) base2 = (2^0 + 2^2) = (1 + 4) = (5) base10
(.011) base2 = 0/2 + 1/4 + 1/8 = 3/8
So in total the decimal conversion would be
5 3/8 = 5.375
Decimal numbers cannot be represented in binary. It has to be whole numbers.
Here is a simple system
Let's take your binary number for example.
101011
Every position represents a power of 2. With the left-most position representing the highest power of 2s. To visualize this, we can do the following.
1 0 1 0 1 1
2 ^ 6 2 ^ 5 2 ^ 4 2 ^ 3 2 ^ 2 2 ^ 1
We go by each position and do this math
1 * (2 ^6 ) + 0 * (2 ^ 5) + 1 * (2 ^ 4) + 0 * (2 ^ 3) + 1 * (2 ^ 2) + 1 * (2 ^ 1)
Doing the math gives us
(1 * 64) + (0 * 32) + (1 * 16) + (0 * 8) + (1 * 4) + (1 * 2) =
64 + 0 + 16 + 0 + 4 + 2 = 86
We get an answer of 86 this way.
Related
I have functional equation
B(2z^4 + 4z^6 + 9z^8 + 20z^{10} + 44z^{12} + 96z^{14}) = (B(z))^4
I try to solve it using Maxima CAS :
(%i2) e: B(2*z^4 + 4*z^6 + 9*z^8 + 20*z^10 + 44*z^12 + 96*z^14) = (B(z))^4;
14 12 10 8 6 4 4
(%o2) B(96 z + 44 z + 20 z + 9 z + 4 z + 2 z ) = B (z)
(%i3) funcsolve (e,B(z));
expt: undefined: 0 to a negative exponent.
#0: rform(%r=[0,0])
#1: funcsol(%a=B(96*z^14+44*z^12+20*z^10+9*z^8+4*z^6+2*z^4) = B(z)^4,%f=B(z),l%=[])
#2: funcsolve(%a=B(96*z^14+44*z^12+20*z^10+9*z^8+4*z^6+2*z^4) = B(z)^4,%f=B(z))
#3: funcsolve(_l=[B(96*z^14+44*z^12+20*z^10+9*z^8+4*z^6+2*z^4) = B(z)^4,B(z)])
-- an error. To debug this try: debugmode(true);
Here simpler example :
define(f(z),z^2-1)
(%o3) f(z):=z^2-1
(%i4) f2:factor(f(f(z)))
(%o4) z^2*(z^2-2)
(%i5) e:B(f2) = B(z)^2
(%o5) B(z^2*(z^2-2)) = B(z)^2
(%i6) s:funcsolve(e,B(z))
expt: undefined: 0 to a negative exponent.
#0: rform(%r=[0,0])
#1: funcsol(%a=B(z^2*(z^2-2)) = B(z)^2,%f=B(z),l%=[])
#2: funcsolve(%a=B(z^2*(z^2-2)) = B(z)^2,%f=B(z))
#3: funcsolve(_l=[B(z^2*(z^2-2)) = B(z)^2,B(z)])
-- an error. To debug this try: debugmode(true);
How should I do it?
Is it another software / method for it ?
so this is my multiplication function:
multiplicacion n 1 = n
multiplicacion n m = n + (multiplicacion n (m - 1))
works with integers but when attempting to multiply floats:
*Main> multiplicacion 4.1 4
16.4
that works but if the second argument is also a float, this happens:
*Main> multiplicacion 4 4.1
the function breaks.
To see what's happening, unroll the function execution - i.e. repeatedly replace function call with its body.
Let's consider the first example:
multiplication 4.1 4
= 4.1 + (multiplication 4.1 (4 - 1))
= 4.1 + (4.1 + (multiplicaiton 4.1 (3 - 1))
= 4.1 + (4.1 + (4.1 + (multiplicaiton 4.1 (2 - 1)))
= 4.1 + (4.1 + (4.1 + 4.1)
= 16.4
Now let's look at the second example:
multiplication 4 4.1
= 4 + (multiplication 4 (4.1 - 1))
= 4 + (4 + (multiplication 4 (3.1 - 1)))
= 4 + (4 + (4 + (multiplication 4 (2.1 - 1))))
= 4 + (4 + (4 + (4 + (multiplication 4 (1.1 - 1)))))
= 4 + (4 + (4 + (4 + (4 + (multiplication 4 (0.1 - 1)))))
= 4 + (4 + (4 + (4 + (4 + (4 + (multiplication 4 (-0.9 - 1))))))
= 4 + (4 + (4 + (4 + (4 + (4 + (4 + (multiplication 4 (-1.9 - 1)))))))
= 4 + (4 + (4 + (4 + (4 + (4 + (4 + (4 + (multiplication 4 (-2.9 - 1))))))))
... and so on
The second argument will never be equal to one, and therefore the first definition multiplication n 1 = n will never match, and therefore the function will forever call itself.
Your function can only multiply by positive integer numbers. Giving it a fractional number results in an infinite loop.
The problem is that you're decrementing m by 1 every call. So let's look what happens with mult 4 4.1, expanding each line:
mult 4 4.1
4 + (mult 4 3.1)
4 + (4 + (mult 4 2.1))
4 + (4 + (4 + (mult 4 1.1)))
4 + (4 + (4 + (4 + (mult 4 0.1)))))
4 + (4 + (4 + (4 + (4 + (mult 4 (-0.9)))))))
...
based on this expansion, can you see what's going wrong here? Because at no stage does m actually equal 1, you never hit the base case.
I'm taking a class on digital logic and I am having a hard time with boolean algebra and simplifying logic functions with it. I have tried answering this problem several times and I keep coming to the answer "1", which I feel is absolutely wrong.
The question is
Consider the logic function f(a,b,c) = abc + ab'c + a'bc + a'b'c + ab'c'. Simplify f using Boolean algebra as much as possible.
I have tried solving it several ways using the boolean identities given in my textbook and from lecture, but I keep coming to something like c + 1 which is equivalent to 1, which I don't feel is the correct answer considering the next question in the problem.
Here is my last attempt:
f(a,b,c) = abc + ab'c + a'bc + a'b'c + ab'c'
= a(bc + b'c + b'c') + a'(bc + b'c) # Distributive, took out the a and the a' separately.
= (a + a')((bc + b'c + b'c') + (bc + b'c)) # Distributive(?), took out the a and a' together (This is probably where I screwed up).
= (1)((c + b'c') + c) # a + a' = 1; bc + b'c = c (Combining).
= c + b'c' + c # cleaned up a little.
= c + b'c' # c + c = c.
= c + (b' + c') # b'c' = b' + c' (DeMorgan's Theorem).
= 1 + b' # c + c' = 1.
= 1 # 1 + b' = 1
This feels absolutely wrong to me, and the next question asks me to make the logic circuit for it, which I don't think is possible.
Can anyone help/walk me through what I am doing wrong? I would really appreciate it. :(
(P.S. I used code formatting, I apologize if this is annoying to some.)
By this table:
A 1 1 1 1 0 0 0 0
B 1 1 0 0 1 1 0 0
C 1 0 1 0 1 0 1 0
Y 1 0 1 1 1 0 1 0
Y=ab'+c
I've got it :D
f(a,b,c) = abc + ab'c + a'bc + a'b'c + ab'c'
= a(bc + b'c + b'c') + a'(bc + b'c)
= a(c(b + b') + b'c') + a'(c(b + b'))
= a(c * 1 + b'c') + a'(c * 1)
= a(c + b'c') + a'c
= a(c'(b'c')')' + a'c
= a(c'(b + c))' + a'c
= a(c'b +cc')' + a'c
= a(c'b)' + a'c
= a(c+b') + a'c
= ac + ab' + a'c
= c(a + a') + ab'
= ab' + c
What is 1.01 binary in decimal?
Just remember we use positional numbering system.
1101 = 2^0 + 2^2 + 2^3 = 1 + 4 + 8 = 13
1.01 = 2^0 + 2^(-2) = 1 + 1/4 = 1.25
Positions to the left of the unit multiply by 2 each time. Positions to the right of the unit divide by 2 each time.
1 . 0 1
1×1 + 0×1/2 + 1×1/4 = 1 1/4
It's 1.25:
1 * 2^0 + 0 * 2^-1 + 1 * 2^-2
= 1 * 1 + 0 * 0.5 + 1 * 0.25
= 1 + 0.25
= 1.25
I understand that the first bit is the sign and that the next 8 bits is the exponent. So in this example you would have 1.1001*2^-4 ? How do I then interpret this in decimal?
0 01111011 10010000000000000000000
Since you already figured out that this is (in binary)1.1001*10^-100, now you just have to convert the binary number to decimal.
In decimal, each digit has a value one-tenth as much as the one before it. In binary, each digit has a value one-half as much as the one before it.
First 1.1001*10^-100 = 0.00011001.
Which is...
0 * 1 0 * 1
+ 0 * 1/2 + 0 * 0.5
+ 0 * 1/4 + 0 * 0.25
+ 0 * 1/8 + 0 * 0.125
+ 1 * 1/16 + 1 * 0.0625
+ 1 * 1/32 + 1 * 0.03125
+ 0 * 1/64 + 0 * 0.015625
+ 0 * 1/128 + 0 * 0.0078125
+ 1 * 1/256 + 1 * 0.00390625
0.0625 + 0.03125 + 0.00390625 = 0.09765625
That's all there is to it.
1.1001b is 1*1 + 0.5*1 + 0.25*0 + 0.125*0 + 0.0625*1, or 1.5625. Multiply that by 2**-4 (0.0625) to get 0.09765625.
in C:
int fl = *(int*)&floatVar;