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
5f1a3be9
Commit
5f1a3be9
authored
Dec 10, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug120
R=r OCL=20921 CL=20921
parent
fbfc9ddd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
mparith3.c
src/cmd/gc/mparith3.c
+17
-8
No files found.
src/cmd/gc/mparith3.c
View file @
5f1a3be9
...
...
@@ -161,7 +161,7 @@ double
mpgetflt
(
Mpflt
*
a
)
{
int
s
,
i
;
uvlong
v
;
uvlong
v
,
vm
;
double
f
;
if
(
a
->
val
.
ovf
)
...
...
@@ -186,22 +186,31 @@ mpgetflt(Mpflt *a)
// independently or in the 6g half of the compiler
// pick up the mantissa in a uvlong
s
=
6
3
;
s
=
5
3
;
v
=
0
;
for
(
i
=
Mpnorm
-
1
;
s
>=
Mpscale
;
i
--
)
{
v
=
(
v
<<
Mpscale
)
|
a
->
val
.
a
[
i
];
s
-=
Mpscale
;
}
vm
=
v
;
if
(
s
>
0
)
vm
=
(
vm
<<
s
)
|
(
a
->
val
.
a
[
i
]
>>
(
Mpscale
-
s
));
// continue with 64 more bits
s
+=
64
;
for
(;
s
>=
Mpscale
;
i
--
)
{
v
=
(
v
<<
Mpscale
)
|
a
->
val
.
a
[
i
];
s
-=
Mpscale
;
}
if
(
s
>
0
)
v
=
(
v
<<
s
)
|
(
a
->
val
.
a
[
i
]
>>
(
Mpscale
-
s
));
// 63 bits of mantissa being rounded to 53
//
should do this in multi precisio
n
if
(
(
v
&
0x3ffULL
)
!=
0x200ULL
||
(
v
&
0x400
)
!=
0
)
v
+=
0x200ULL
;
// round toward even
//print("vm=%.16llux v=%.16llux\n", vm, v);
//
round toward eve
n
if
(
v
!=
(
1ULL
<<
63
)
||
(
vm
&
1ULL
)
!=
0
)
v
m
+=
v
>>
63
;
v
>>=
10
;
f
=
(
double
)(
v
);
f
=
(
double
)(
vm
);
f
=
ldexp
(
f
,
Mpnorm
*
Mpscale
+
a
->
exp
-
53
);
if
(
a
->
val
.
neg
)
...
...
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