Skip to content

Instantly share code, notes, and snippets.

@alex-leonhardt
Last active April 9, 2020 12:07
Show Gist options
  • Save alex-leonhardt/2de40d6d90a1189c5851ec4682706b98 to your computer and use it in GitHub Desktop.
Save alex-leonhardt/2de40d6d90a1189c5851ec4682706b98 to your computer and use it in GitHub Desktop.
bit shifty things
package main
import (
"fmt"
"math"
)
func main() {
v := 1 << 40
fmt.Println(v, "= 1 Tera")
v = 1 << 30
fmt.Println(v, "= 1 Giga")
v = 2 << 20
fmt.Println(v, "= 2 Mega")
v = 1 << 20
fmt.Println(v, "= 1 Mega")
v = 1 << 10
fmt.Println(v, "= 1 Kilo")
// --------------------------------
w := math.Pow(2, 3)
fmt.Println(w)
v = 1 << 8
w = math.Pow(2, 8)
fmt.Println(v, w)
v = 2 << 8
w = math.Pow(2, 9)
fmt.Println(v, w)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment