File: left_shift.rb

package info (click to toggle)
dlr-languages 20090805%2Bgit.e6b28d27%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 51,484 kB
  • ctags: 59,257
  • sloc: cs: 298,829; ruby: 159,643; xml: 19,872; python: 2,820; yacc: 1,960; makefile: 96; sh: 65
file content (34 lines) | stat: -rw-r--r-- 905 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
p 1 << 30
p 1 << 31
p 1 << 32
p 1 << 33

#                          
p 0b01000000_00000000_00000000_00000000 << 1
p 0b00100000_00000000_00000000_00000000 << 1
p 0b00100000_00000000_00000000_00000000 << 2
p 0b00000000_00000000_10000000_00000000 << 14
p 0b00000000_00000000_10000000_00000000 << 15
p 0b00000000_00000000_10000000_00000000 << 16
p 0b00000000_00000000_10000000_00000000 << 17

p (-1) << 1
p (-1) << 2
p (-1) << 3
p (-1) << 29
p (-1) << 31
p (-1) << 32
p (-1) << 33
p (-1) << 34

p (-0b01000000_00000000_00000000_00000000) << 1
p (-0b00100000_00000000_00000000_00000000) << 1
p (-0b00100000_00000000_00000000_00000000) << 2
p (-0b00000000_00000000_10000000_00000000) << 14
p (-0b00000000_00000000_10000000_00000000) << 15
p (-0b00000000_00000000_10000000_00000000) << 16
p (-0b00000000_00000000_10000000_00000000) << 17

p r = [192,168,1,1].inject(0) { |n,i| (n <<= 8) + i }
p r.class
p r.size