github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/test/fixedbugs/bug470.go (about) 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 // Converting constants between types must introduce rounding. 8 9 package main 10 11 import "fmt" 12 13 const ( 14 F32 = 0.00999999977648258209228515625 15 F64 = 0.01000000000000000020816681711721685132943093776702880859375 16 ) 17 18 var F = float64(float32(0.01)) 19 20 func main() { 21 // 0.01 rounded to float32 then to float64 is F32. 22 // 0.01 represented directly in float64 is F64. 23 if F != F32 { 24 panic(fmt.Sprintf("F=%.1000g, want %.1000g", F, F32)) 25 } 26 }