Home | History | Annotate | Download | only in fixedbugs
      1 // run
      2 
      3 // Copyright 2012 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 // Test that typed and untyped negative zero floating point constants
      8 // are treated as equivalent to zero constants.
      9 
     10 package main
     11 
     12 import "math"
     13 
     14 const zero = 0.0
     15 
     16 func main() {
     17 	x := -zero
     18 	b := math.Float64bits(x)
     19 	if b != 0 {
     20 		panic(b)
     21 	}
     22 	x = -float64(zero)
     23 	b = math.Float64bits(x)
     24 	if b != 0 {
     25 		panic(b)
     26 	}
     27 	v := x
     28 	b = math.Float64bits(-v)
     29 	if b != 0x8000000000000000 {
     30 		panic(b)
     31 	}
     32 }
     33