binary conversion using 3 figures system 0,1,2 - binary

Suppose system is evolved by extraterrestrial creatures having only 3 figures and they use the figures 0,1,2 with (2>1>0) ,How to represent the binary equivalent of 222 using this?
I calculated it to be 22020 but the book answers it 11010 .how this.Shouldn't i use the same method to binary conversion as from decimal to binary except using '3' here ???

I think you meant base 3 (not binary) equivalent of decimal 222
22020 in base 3 is 222 in decimal.
220202(your answer) in base 3 is 668 in decimal.
11010 (according to book) in base 3 is 111 in decimal.
222 in binary is 11011110
May be i will be able to tell where you went wrong if you tell the method you used to calculate base 3 equivalent of 222
Edit:
Sorry I could not understand the problem until you provide the link. It says what is binary equivalent of 222 (remember 222 is in base 3)
222 in base 3 = 26 in decimal (base 10)
26 in decimal = 11010 in binary
Mark it as accepted if it solved your problem.

Assuming the start is decimal 222.
Well, without knowing the system used in the book I would decompose it by hand in the following way:
3^4 = 81,
3^3 = 27,
3^2 = 9,
3^1 = 3,
So 81 fits twize into 222 , so the 4th "bit" has the value 2.
Remaining are 60. 27 fits twice into 60 so the next bit is 2 again.
Remaining are 6. 9 fits not into 6, so the next bit is 0.
Remaining are 6. 3 fits twice into 6, so the next bit is 2.
remaining are 0. so the last bit 0
This gives as result 22020.
One quick sanity check on how many "bits" are needed for representation of decimal 222 in a number system with 3 Numbers: 1+log(222)/log(3)=5,9 => nearly 6 "bits" are needed, which goes well with the result 22020.

First see how many figures you have, here we have 3 so
we have to convert 222 to binary when we have only 3 figures so
2×3^2+2×3^1+2×3^0 (if the number were being 121 then →
1×3^2+2×3^1+1×3^0)
which gives 26 then divide this with 2 until we don't get 1/2
when reminder is 1 then write 1 if 0 then 0 you will get
so we get 01011 just reverse it we have the answer
11010
enter image description here

Related

the carry in most significant bit(on 3 digits)

Consider the two's complement representation on 3 bits:
3+2 causes overflow.
011+010=100 // why is it 100? I think it should be 101.
And what are the carry in to the most significant bit and carry out from the most significant bit in this case?
the textbook says the carry in to the most significant bit is 1, the carry out from the most significant bit is 0.
I think the text book is wrong. the carry in should be 0 and the carry out should be 1. Am I correct or the textbook is correct?
Please help. Thanks.
Textbook
Right and wrong, I would say, just like so much of life :-)
You're correct in stating that 011 + 010 = 101. The link you posted gave the 100 value of -4 which is a correct interpretation of that value, though not the correct value.
You can generally get the overflowed value by adding the two values without taking overflow into account, then subtracting the range (eight for a three-bit value) if it's more than half the range less one.
In other words, 3 + 2 = 5 but, since this is greater than three (half range less one), you subtract the range 8 to get -3, which is what your correct bit pattern is, 101:
Bit pattern Unsigned Signed
----------- -------- ------
000 0 0
001 1 1
010 2 2
011 3 3
100 4 -4
101 5 -3
110 6 -2
111 7 -1
However, adding the middle bits (with no carry over from the right bits) does actually give you a result of zero and carry of one.
That means the carry into the MSB (left bit) is indeed one. And, when adding those left digits (both zero) with that carry of one, you get one with a carry out of zero.
It may be that you're reading the textbook differently to me but we may have to give it the benefit of the doubt here.

1 in ASCII and 1 in Binary. Same thing?

So, this question goes in the computer science world.
So, if we write number 1 in binary it will give us:
00000001
but we know that if 0 = 48, then 1 = 49 (in ASCII). So, if we represent 49:
00110001
are those two numbers the same?

Convert a 16 Bit Binary Value to Octal

Hello I would like to know of a quick and easy way to perform a number conversion of this binary value:
1000100000001011
to octal.
In hex I can convert fairly quickly by hand to 0xAA0B. To come up with the decimal value of this binary takes a bit more work but eventually you can arrive at 32,768 + 2,048 + 11 = 34,827.
I know the octal pattern works like 8 = 10, 9 = 11 .... 16 = 20, 17 = 21 ... 24 = 30, etc. However I am having trouble converting to octal without a large amount of effort.
Could anybody clear this up for me and perhaps provide a short-hand method that can help convert binary to octal. Programming examples are nice but I'm really looking for an explanation. Thanks
The quickest method is to break the binary number into 3-bit chunks from the right end, pad with 0's from the left as needed, then convert each chunk to an octal digit.
For example,
1000100000001011 -> 001 000 100 000 001 011 [2 0's added to the left]
-> 1 0 4 0 1 3
-> 104013

Regex Validation YYYYMMDD

So I need a bit of regex for validation in an input in a form.
I believe you can put regex patterns direct into HTML now? (How do I do this?)
I found this, but I'm not sure whether it is what I want?
"(((\\d\\d)(0[48]|[2468][048]|[13579][26])|([02468][048]|[13579][26])(00))(02)([012]\\d))|(\\d\\d([02468][1235679]|[13579][01345789])(02)([01]\\d|2[012345678]))|(\\d\\d\\d\\d((0[13578]|1[02])([012]\\d|3[01])|((0[46]|11)([012]\\d|30))))"
So, first bit:
4 digits, less than x (2017) (Needs to easily changeable?)
second bit:
2 digits, between 01 and 12
third bit:
2 digits, between 01 and 31 (I don't care for per month changes)
I believe this should do it:
(201[0-7]|200[0-9]|[0-1][0-9]{3})(1[0-2]|0[1-9])(3[01]|[0-2][1-9]|[12]0)
Here's an example on RegExr.
Breakdown:
(201[0-7]|200[0-9]|[0-1][0-9]{3}) matches either:
201 followed by a digit between 0 and 7 (2010..2017)
or 200 followed by a digit between 0 and 9 (2000..2009)
or a zero or a one, followed by three digits between 0 and 9 (0000..1999). If you do not wish to show years under 1000, you could simply do (201[0-7]|200[0-9]|1[0-9]{3}).
Note: If you wanna match something over 2020, you can change this segment to (202[0-7]|20[01][0-9]|[0-1][0-9]{3}), allowing anything from 0000..2027
The next segment, (1[0-2]|0[1-9]) matches either:
a 1 followed by a digit between 0 through 2 (10..12)
or a zero followed by a digit between 1 through 9 (01..09)
The last one, (3[01]|[0-2][1-9]|[12]0), matches either:
a 3 followed by 0 or 1 (30..31)
or a digit between 0 and 2 followed by a digit between 1 and 9 (01..29)
or 2 or 1 followed by a 0, since the rule above does not allow the number to end on zero (shutting out 00).
I feel there is a minor problem in Dencker's Answer to accomodate the dates 10 and 20th of the month.
(201[0-7]|200[0-9]|[0-1][0-9]{3})(1[0-2]|0[1-9])(3[01]|[0-2][1-9]|[12][0])
** Unable to comment on the Dencker's Post (Need 50 reputation score to comment)

Find the complement using base 9

I have this simple problem which for some reason I have trouble with I'll be glad to get help.
I have these two numbers in base 10 :
5250, 321.
I change the basis from 10 to 9 then I get :
5250 --> 7173
321 ---> 386
I use the method of r complement with base 9:
First of all I'll find the the complement of 0386 in base 9 which is 6561-386=6175.
Therefore :
7173+6175=14358 (in base 9)
since its a complement to 9, we receive 4358 in base 9
Which is incorrect.
Any ideas why my method is incorrect?
Any help will be appreciated.
you are mixing bases. 6561 is base 10 for 10000 in base 9.
You need to calculate 100000 - 386 in base 9 to get the complement. This results in 88503. So 88503 is the 10's complement of 386 in base 9. Note the extra digit, otherwise 7173 will be a negative number in this representation.
Now you can calculate 7173 + 88503 = 106676. So the result is 6676 which is 4929 in decimal, which is the expected result.