-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path25_bit_shift_assignment.go
More file actions
41 lines (33 loc) · 967 Bytes
/
25_bit_shift_assignment.go
File metadata and controls
41 lines (33 loc) · 967 Bytes
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
35
36
37
38
39
40
41
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Šestá část
// Konstrukce pro řízení běhu programu v jazyce Go (dokončení)
// https://www.root.cz/clanky/konstrukce-pro-rizeni-behu-programu-v-jazyce-go-dokonceni/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů ze šesté části:
// https://github.com/tisnik/go-root/blob/master/article_06/README.md
//
// Demonstrační příklad číslo 25:
// Bitové posuny zkombinované s přiřazením.
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_06/25_bit_shift_assignment.html
package main
import "fmt"
func main() {
x := 1
for i := uint(0); i <= 10; i++ {
fmt.Printf("%d << %2d == %4d\n", 1, i, x)
x <<= 1
}
fmt.Println()
x = 10000000
for i := uint(0); i <= 10; i++ {
fmt.Printf("%d >> %2d == %4d\n", 1, i, x)
x >>= 1
}
}