Debian Codegraph @

test/fixedbugs/issue30243.go

raw
1 // run
2
3 // Copyright 2019 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 // Compile-time constants, even if they cannot be represented
8 // accurately, should remain the same in operations that don't
9 // affect their values.
10
11 package main
12
13 import "fmt"
14
15 func main() {
16 const x = 0.01
17 const xi = 0.01i
18 const xc = complex(0, x)
19
20 if imag(xi) != x {
21 fmt.Printf("FAILED: %g != %g\n", imag(xi), x)
22 }
23
24 if xi != complex(0, x) {
25 fmt.Printf("FAILED: %g != %g\n", xi, complex(0, x))
26 }
27 }