hey guys can you help me to understand why 00000100 is 64 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

hey guys can you help me to understand why 00000100 is 64 ?

17th Aug 2018, 8:09 AM
Real Gutch
Real Gutch - avatar
15 Answers
+ 5
guys the position of 1 is the 3rd
17th Aug 2018, 8:17 AM
Real Gutch
Real Gutch - avatar
+ 5
at 3rd position is 4bit
17th Aug 2018, 8:17 AM
Real Gutch
Real Gutch - avatar
+ 5
always raise in 3
17th Aug 2018, 8:38 AM
Real Gutch
Real Gutch - avatar
+ 4
001000000 = 2^6 =64 counting from the right, the first spot has value 2^0, the second 2^1 and so on. The 1 is in place with value 2^6.
17th Aug 2018, 8:14 AM
davy hermans
davy hermans - avatar
+ 4
so it actually is equal to 4 but we assumed it was read backwards
17th Aug 2018, 8:18 AM
davy hermans
davy hermans - avatar
+ 4
ill try this in c ex: int x = 00000100; printf("%d",x); result: 64 why??
17th Aug 2018, 8:19 AM
Real Gutch
Real Gutch - avatar
+ 4
but if we read backward the result is 32 because the 64 is the second position start from last
17th Aug 2018, 8:23 AM
Real Gutch
Real Gutch - avatar
+ 4
128,64,32,16,8,4,2,1 normal 1,2,4,8,16,32,64,128 backwards my position of my 1's is the 3rd position 😯 in normal and 6th position backwards
17th Aug 2018, 8:27 AM
Real Gutch
Real Gutch - avatar
+ 4
oh guys i know now the formula my 1's is the position of 3rd and the value is 4 now we need it to raise in 3 to get the value 4*4*4 = 64 and if we try in 01000000 you get the value if you raise the bit in 3 😃
17th Aug 2018, 8:37 AM
Real Gutch
Real Gutch - avatar
+ 3
Numbers in C are read in different bases based on the prefix: No prefix -> decimal (base 10) '0' prefix -> octal (base 8) '0x' prefix -> hexadecimal (base 16) '0b' prefix -> binary (base 2) When you write 00000100 the compiler sees that it starts with '0' and assumes it to be base 8. https://code.sololearn.com/cU3TDoNmza71/?ref=app
17th Aug 2018, 8:31 AM
Vlad Serbu
Vlad Serbu - avatar
+ 3
isn't it in octodecimal, 10 = 8, 100 = 8*8 = 64
17th Aug 2018, 9:36 AM
Seb TheS
Seb TheS - avatar
+ 2
64 in binary is: (64)(32)(16)(8)(4)(2)(1) 1. 0. 0. 0. 0 0. 0 what is 12 in binary? 0001100
17th Aug 2018, 8:15 AM
John
John - avatar
+ 2
00000100 is 4, not 64
17th Aug 2018, 8:18 AM
hinanawi
hinanawi - avatar
+ 2
Gutch From Ph Yep and you raise in 3 because it's base 8 (2^3). 010000000 would be 128*128*128, or 8^7.
17th Aug 2018, 8:57 AM
Vlad Serbu
Vlad Serbu - avatar
+ 1
correct, just read it left to right.
17th Aug 2018, 8:24 AM
John
John - avatar