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
9e26c4bd
Commit
9e26c4bd
authored
Dec 13, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: complex(0)
Fixes #1232. R=ken2 CC=golang-dev
https://golang.org/cl/3621041
parent
88cf5564
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
5 deletions
+6
-5
const.c
src/cmd/gc/const.c
+3
-5
mparith1.c
src/cmd/gc/mparith1.c
+2
-0
cmplx.go
test/cmplx.go
+1
-0
No files found.
src/cmd/gc/const.c
View file @
9e26c4bd
...
@@ -202,8 +202,6 @@ convlit1(Node **np, Type *t, int explicit)
...
@@ -202,8 +202,6 @@ convlit1(Node **np, Type *t, int explicit)
goto
bad
;
goto
bad
;
case
CTFLT
:
case
CTFLT
:
case
CTINT
:
case
CTINT
:
if
(
explicit
)
goto
bad
;
n
->
val
=
tocplx
(
n
->
val
);
n
->
val
=
tocplx
(
n
->
val
);
break
;
break
;
case
CTCPLX
:
case
CTCPLX
:
...
@@ -300,7 +298,7 @@ toflt(Val v)
...
@@ -300,7 +298,7 @@ toflt(Val v)
f
=
mal
(
sizeof
(
*
f
));
f
=
mal
(
sizeof
(
*
f
));
mpmovefltflt
(
f
,
&
v
.
u
.
cval
->
real
);
mpmovefltflt
(
f
,
&
v
.
u
.
cval
->
real
);
if
(
mpcmpfltc
(
&
v
.
u
.
cval
->
imag
,
0
)
!=
0
)
if
(
mpcmpfltc
(
&
v
.
u
.
cval
->
imag
,
0
)
!=
0
)
yyerror
(
"constant %#F
truncated to real"
,
v
.
u
.
fval
);
yyerror
(
"constant %#F
%+#Fi truncated to real"
,
&
v
.
u
.
cval
->
real
,
&
v
.
u
.
cval
->
imag
);
v
.
ctype
=
CTFLT
;
v
.
ctype
=
CTFLT
;
v
.
u
.
fval
=
f
;
v
.
u
.
fval
=
f
;
break
;
break
;
...
@@ -324,9 +322,9 @@ toint(Val v)
...
@@ -324,9 +322,9 @@ toint(Val v)
case
CTCPLX
:
case
CTCPLX
:
i
=
mal
(
sizeof
(
*
i
));
i
=
mal
(
sizeof
(
*
i
));
if
(
mpmovefltfix
(
i
,
&
v
.
u
.
cval
->
real
)
<
0
)
if
(
mpmovefltfix
(
i
,
&
v
.
u
.
cval
->
real
)
<
0
)
yyerror
(
"constant %#F
truncated to integer"
,
v
.
u
.
fval
);
yyerror
(
"constant %#F
%+#Fi truncated to integer"
,
&
v
.
u
.
cval
->
real
,
&
v
.
u
.
cval
->
imag
);
if
(
mpcmpfltc
(
&
v
.
u
.
cval
->
imag
,
0
)
!=
0
)
if
(
mpcmpfltc
(
&
v
.
u
.
cval
->
imag
,
0
)
!=
0
)
yyerror
(
"constant %#F
truncated to real"
,
v
.
u
.
fval
);
yyerror
(
"constant %#F
%+#Fi truncated to real"
,
&
v
.
u
.
cval
->
real
,
&
v
.
u
.
cval
->
imag
);
v
.
ctype
=
CTINT
;
v
.
ctype
=
CTINT
;
v
.
u
.
xval
=
i
;
v
.
u
.
xval
=
i
;
break
;
break
;
...
...
src/cmd/gc/mparith1.c
View file @
9e26c4bd
...
@@ -475,6 +475,8 @@ Fconv(Fmt *fp)
...
@@ -475,6 +475,8 @@ Fconv(Fmt *fp)
// for well in range, convert to double and use print's %g
// for well in range, convert to double and use print's %g
if
(
-
900
<
fvp
->
exp
&&
fvp
->
exp
<
900
)
{
if
(
-
900
<
fvp
->
exp
&&
fvp
->
exp
<
900
)
{
d
=
mpgetflt
(
fvp
);
d
=
mpgetflt
(
fvp
);
if
(
d
>=
0
&&
(
fp
->
flags
&
FmtSign
))
fmtprint
(
fp
,
"+"
);
return
fmtprint
(
fp
,
"%g"
,
d
);
return
fmtprint
(
fp
,
"%g"
,
d
);
}
}
// TODO(rsc): for well out of range, print
// TODO(rsc): for well out of range, print
...
...
test/cmplx.go
View file @
9e26c4bd
...
@@ -22,6 +22,7 @@ func main() {
...
@@ -22,6 +22,7 @@ func main() {
c64
=
cmplx
(
f32
,
f32
)
c64
=
cmplx
(
f32
,
f32
)
c128
=
cmplx
(
f64
,
f64
)
c128
=
cmplx
(
f64
,
f64
)
_
=
complex
(
0
)
// ok
_
=
cmplx
(
f
,
f32
)
// ERROR "cmplx"
_
=
cmplx
(
f
,
f32
)
// ERROR "cmplx"
_
=
cmplx
(
f
,
f64
)
// ERROR "cmplx"
_
=
cmplx
(
f
,
f64
)
// ERROR "cmplx"
_
=
cmplx
(
f32
,
f
)
// ERROR "cmplx"
_
=
cmplx
(
f32
,
f
)
// ERROR "cmplx"
...
...
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