Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. // Assuming signed 8-bit integers
  2. 01100101 // How 101 is represented in binary
  3. 00110010 // After right shifting one bit, this represents 50
  4.  
  5. // Assuming signed 8-bit integers
  6. 01100101 // How 101 is represented in binary
  7. 11001010 // After left shifting one bit, this represents -54
  8.  
  9. // Assuming unsigned 8-bit integers
  10. 01100101 // How 101 is represented in binary
  11. 11001010 // After left shifting one bit, this represents 202
  12.  
  13. // Assuming signed 16-bit integers
  14. 00000000 01100101 // How 101 is represented in binary
  15. 00000000 11001010 // After left shifting one bit, this represents 202
  16. 00000001 10010100 // After left shifting one bit again, this represents 404
  17.  
  18. 5287
  19.  
  20. 5287 = (5 * 1000) + (2 * 100) + (8 * 10) + (7 * 1)
  21.  
  22. 5287 = (5 * 10^3) + (2 * 10^2) + (8 * 10^1) + (7 * 10^0)
  23.  
  24. 5287 = 00010100 10100111 (base 2)
  25. = (0 * 2^15) + (0 * 2^14) + (0 * 2^13) + (1 * 2^12)
  26. + (0 * 2^11) + (1 * 2^10) + (0 * 2^9) + (0 * 2^8)
  27. + (1 * 2^7) + (0 * 2^6) + (1 * 2^5) + (0 * 2^4)
  28. + (0 * 2^3) + (1 * 2^2) + (1 * 2^1) + (1 * 2^0)
  29.  
  30. Base 10 : Base 2
  31. 1 : 0001
  32. 2 : 0010
  33. 3 : 0011
  34. 4 : 0100
  35. 5 : 0101
  36. 6 : 0110
  37. 7 : 0111
  38. 8 : 1000
  39.  
  40. class X
  41. {
  42. public static void main(String args[])
  43. {
  44. System.out.println("20>>2 = "+20>>2);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement