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

Side by Side Diff: test/float.go

Issue 3615041: 8g: IEEE overflow, underflow, and subnormals
Patch Set: code review 3615041: 8g: IEEE overflow, underflow, and subnormals Created 13 years, 3 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 | « src/pkg/runtime/386/asm.s ('k') | 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 // $G $F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2010 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 package main
8
9 import (
10 "fmt"
11 "math"
12 )
13
14 func main() {
15 var a float64 = math.MaxFloat64
16 check("a := MaxFloat64; a*a/a", a*a/a, math.Inf(1))
17 a = math.SmallestNonzeroFloat64
18 check("a := SmallestNonzeroFloat64; a*a/a", a*a/a, 0)
19 var b float32 = math.MaxFloat32
20 check("b := MaxFloat32; b*b/b", float64(b*b/b), math.Inf(1))
21 b = math.SmallestNonzeroFloat32
22 check("b := SmallestNonzeroFloat32; b*b/b", float64(b*b/b), 0)
23 var h, i float64 = 1.3333333333333333, 1e+308
24 check("1.3333333333333333/1e+308", h/i, 1.333333333333333e-308)
25 h = 3.3376107877608026e-308
26 i = 4.503599627370497e+15
27 check("3.3376107877608026e-308/4.503599627370497e+15", h/i, 5e-324)
28 }
29
30 var bad = false
31
32 func check(name string, a, b float64) {
33 if a == b {
34 return
35 }
36 if !bad {
37 bad = true
38 fmt.Println("BUG: float")
39 }
40 fmt.Printf("%s = %g, want %g\n", name, a, b)
41 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/386/asm.s ('k') | no next file » | no next file with comments »

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