| 1 |
// run |
| 2 |
|
| 3 |
// Copyright 2021 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
// Verify exact constant evaluation independent of |
| 8 |
// (mathematically equivalent) expression form. |
| 9 |
|
| 10 |
package main |
| 11 |
|
| 12 |
import "fmt" |
| 13 |
|
| 14 |
const ulp1 = imag(1i + 2i / 3 - 5i / 3) |
| 15 |
const ulp2 = imag(1i + complex(0, 2) / 3 - 5i / 3) |
| 16 |
|
| 17 |
func main() { |
| 18 |
if ulp1 != ulp2 { |
| 19 |
panic(fmt.Sprintf("%g != %g\n", ulp1, ulp2)) |
| 20 |
} |
| 21 |
} |