Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(447)

Side by Side Diff: test/fixedbugs/bug470.go

Issue 6855053: code review 6855053: test: add test for floating point rounding of constants (Closed)
Patch Set: diff -r b5f58df8efce https://go.googlecode.com/hg/ Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b