Oleksandr Redko | 97c56ed | 2024-06-25 17:41:30 +0300 | [diff] [blame] | 1 | //go:build OMIT |
Andrew Gerrand | 8775c8e | 2014-02-24 14:28:32 +1100 | [diff] [blame] | 2 | |
Andrew Gerrand | 009a79d | 2013-01-23 17:39:23 +1100 | [diff] [blame] | 3 | package main |
| 4 | |
| 5 | import "fmt" |
| 6 | |
| 7 | const ( |
Katrina Owen | 1ae3b95 | 2016-02-09 08:32:19 +1100 | [diff] [blame] | 8 | // Create a huge number by shifting a 1 bit left 100 places. |
| 9 | // In other words, the binary number that is 1 followed by 100 zeroes. |
| 10 | Big = 1 << 100 |
| 11 | // Shift it right again 99 places, so we end up with 1<<1, or 2. |
| 12 | Small = Big >> 99 |
Andrew Gerrand | 009a79d | 2013-01-23 17:39:23 +1100 | [diff] [blame] | 13 | ) |
| 14 | |
| 15 | func needInt(x int) int { return x*10 + 1 } |
| 16 | func needFloat(x float64) float64 { |
| 17 | return x * 0.1 |
| 18 | } |
| 19 | |
| 20 | func main() { |
| 21 | fmt.Println(needInt(Small)) |
| 22 | fmt.Println(needFloat(Small)) |
| 23 | fmt.Println(needFloat(Big)) |
| 24 | } |