Last active
November 1, 2016 11:52
-
-
Save nanoninja/6d8d0953849d72c41d65e4c1194b0fdd to your computer and use it in GitHub Desktop.
Binary iota accu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Letter uint16 | |
const ( | |
A Letter = 1 << iota | |
B | |
C | |
D | |
All = (D << 1) - A | |
) | |
func main() { | |
fmt.Printf("01. %08b, %[1]d\n", A) // 01. 00000001, 1 | |
fmt.Printf("02. %08b, %[1]d\n", B) // 02. 00000010, 2 | |
fmt.Printf("03. %08b, %[1]d\n", C) // 03. 00000100, 4 | |
fmt.Printf("04. %08b, %[1]d\n", D) // 04. 00001000, 8 | |
fmt.Printf("05. %08b, %[1]d\n", All) // 05. 00001111, 15 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment