Created
February 13, 2018 11:25
-
-
Save SatoTakeshiX/04b02d53d07c454a0e327e3916ad3524 to your computer and use it in GitHub Desktop.
定義を上からしなくてもよい。Smallでしたの方に定義したBit定数を使える #read_go #CodePiece
This file contains 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 | |
import "fmt" | |
const ( | |
// Shift it right again 99 places, so we end up with 1<<1, or 2. | |
Small = Big >> 99 | |
// Create a huge number by shifting a 1 bit left 100 places. | |
// In other words, the binary number that is 1 followed by 100 zeroes. | |
Big = 1 << 100 | |
) | |
func needInt(x int) int { return x*10 + 1 } | |
func needFloat(x float64) float64 { | |
return x * 0.1 | |
} | |
func main() { | |
fmt.Println(needInt(Small)) | |
fmt.Println(needFloat(Small)) | |
fmt.Println(needFloat(Big)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment