Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
f333f468
Commit
f333f468
authored
Nov 17, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
floating point constant errors in 6g
R=r OCL=19379 CL=19379
parent
75647d20
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
bug120.go
test/bugs/bug120.go
+39
-0
No files found.
test/bugs/bug120.go
0 → 100644
View file @
f333f468
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug120
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
import
"strconv"
;
type
Test
struct
{
f
float64
;
in
string
;
out
string
;
}
var
tests
=
[]
Test
{
Test
{
123.5
,
"123.5"
,
"123.5"
},
Test
{
456.7
,
"456.7"
,
"456.7"
},
Test
{
1e23
+
8.5e6
,
"1e23+8.5e6"
,
"1.0000000000000001e+23"
},
Test
{
100000000000000008388608
,
"100000000000000008388608"
,
"1.0000000000000001e+23"
},
Test
{
1e23
+
8.388608e6
,
"1e23+8.388608e6"
,
"1.0000000000000001e+23"
},
Test
{
1e23
+
8.388609e6
,
"1e23+8.388609e6"
,
"1.0000000000000001e+23"
},
}
func
main
()
{
ok
:=
true
;
for
i
:=
0
;
i
<
len
(
tests
);
i
++
{
t
:=
tests
[
i
];
v
:=
strconv
.
ftoa64
(
t
.
f
,
'g'
,
-
1
);
if
v
!=
t
.
out
{
println
(
"Bad float64 const:"
,
t
.
in
,
"want"
,
t
.
out
,
"got"
,
v
);
ok
=
false
;
}
}
if
!
ok
{
panicln
(
"bug120"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment