// A shift's result type follows the left operand, not the count. Where the // left operand is an untyped constant too wide for the count's type, adopting // the count's type truncated it: `0x20000000000000 >> uint32(k)` computed 0 // where Go computes 2^49. math.expm1 relies on this expression, so the whole // function returned 0 for the affected branch. package main func shifted(k uint32) (r uint64) { return uint64(0x20000000000000 >> k) } func combined(k uint32) (r uint64) { return uint64(0x3ff0000000000000 - (0x20000000000000 >> k)) } func main() { if shifted(0) != 9007199254740992 { panic("shift truncated the left operand") } if shifted(10) != 9007199254740992>>10 { panic("shift by 10 truncated the left operand") } if combined(0) != 4598175219545276416 { panic("subtraction over the shift was wrong") } if combined(20) != 4607182410210082816 { panic("subtraction over the shift was wrong at 20") } println(combined(0)) }