+ 3
It's a left shift operation.. See this for more clarity.. edit : 𝕱𝖎𝖗𝖊𝖆𝖗𝖒𝖘 int x=5; x<<=3 => means x=x<<3 x =5 => in binary 00000101 x=x<<3 => after 3 left bit shifts 00101000 = 40 x=40 https://www.sololearn.com/learn/4087/?ref=app
10th Feb 2022, 7:07 PM
Jayakrishna 🇮🇳
+ 1
5 is integer. Java allocates 4 bytes for integer so totally, 4*8=32bits each bit store 0 or 1 . So actually it is in system : 00000000 00000000 00000000 00000101 But just using first multiple of 8 bits for readability... 101 is the value remaining all bits are set 0 Just like a number 0099 is 99 , if there is 4 digit slot, we add 0. edit: https://introcs.cs.princeton.edu/java/61data/
10th Feb 2022, 7:59 PM
Jayakrishna 🇮🇳
0
Oh. That's complex, I don't think it work. If you run, you get zero only I think. Because int is of 4bytes so its has 4*8=32 bits only.. Maximum you can shift 32 bits.. (value 1928118 is too high) I added example already in my first post.. x = 5 in binary its value is 00000101 x<<3 means shift 3 bits of x value towards left and zeros will be appended at right 0 0 0 0 0 1 0 1 / / / 0 0 1 0 1 shifted left append zeros at right shifted places 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 1 = 5 / / / 0 0 1 0 1 0 0 0 = 40 This is equalent to 40 in decimal.
10th Feb 2022, 7:28 PM
Jayakrishna 🇮🇳
0
Ex: 25 2 | 25 | | 12 | 1 //see below comment | 6 | 0 | 3 | 0 | 1 | 1 | 0 | 1 ^ 25 in decimal 11001 in binary, (from below to up) 2 | 25 | | 12 | 1 //here 2 divided by 25 , quotient 12 reminder is 1 => 25/2=12 , 25%2=1 Ex: for 2 2 | 2 | | 1 | 0 | 0 | 1 ^ 10 You can stop this at last you dividend 0. 2 => in binary is 10 Add trailing zeros as much as needed 0000 0010 @ 𝕱𝖎𝖗𝖊𝖆𝖗𝖒𝖘 you can find many online sources, videos on this topic, if it is not clear yet... hope it helps... edit: 𝕱𝖎𝖗𝖊𝖆𝖗𝖒𝖘 https://www.cuemath.com/numbers/decimal-to-binary/ https://www.wikihow.com/Convert-from-Decimal-to-Binary https://introcs.cs.princeton.edu/java/61data/
10th Feb 2022, 7:42 PM
Jayakrishna 🇮🇳