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

Delta Between Two Patch Sets: src/pkg/math/bits.go

Issue 6344078: code review 6344078: math, runtime: use a NaN that matches gcc's (Closed)
Left Patch Set: diff -r 136f59f1d047 https://code.google.com/p/go/ Created 11 years, 8 months ago
Right Patch Set: diff -r 4bd268b3c88a https://code.google.com/p/go/ Created 11 years, 7 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/math/all_test.go ('k') | src/pkg/runtime/float.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package math 5 package math
6 6
7 const ( 7 const (
8 » uvnan = 0x7ff8000000000000 8 » uvnan = 0x7FF8000000000001
9 uvinf = 0x7FF0000000000000 9 uvinf = 0x7FF0000000000000
10 uvneginf = 0xFFF0000000000000 10 uvneginf = 0xFFF0000000000000
11 mask = 0x7FF 11 mask = 0x7FF
12 shift = 64 - 11 - 1 12 shift = 64 - 11 - 1
13 bias = 1023 13 bias = 1023
14 ) 14 )
15 15
16 // Inf returns positive infinity if sign >= 0, negative infinity if sign < 0. 16 // Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.
17 func Inf(sign int) float64 { 17 func Inf(sign int) float64 {
18 var v uint64 18 var v uint64
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 // normalize returns a normal number y and exponent exp 51 // normalize returns a normal number y and exponent exp
52 // satisfying x == y × 2**exp. It assumes x is finite and non-zero. 52 // satisfying x == y × 2**exp. It assumes x is finite and non-zero.
53 func normalize(x float64) (y float64, exp int) { 53 func normalize(x float64) (y float64, exp int) {
54 const SmallestNormal = 2.2250738585072014e-308 // 2**-1022 54 const SmallestNormal = 2.2250738585072014e-308 // 2**-1022
55 if Abs(x) < SmallestNormal { 55 if Abs(x) < SmallestNormal {
56 return x * (1 << 52), -52 56 return x * (1 << 52), -52
57 } 57 }
58 return x, 0 58 return x, 0
59 } 59 }
LEFTRIGHT

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