Closed
Bug 5301
Opened 25 years ago
Closed 25 years ago
Errors in Math.round();
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
VERIFIED
FIXED
M6
People
(Reporter: rginda, Assigned: mike+mozilla)
Details
With js-1.4-2:
js> Math.round(1.0001);
1.0000004768371582
js>
rginda@ix.netcom.com
norris can you look at this or reassign to someone? it's happening on linux
but not on other NT, solaris, IRIX.
Comment 2•25 years ago
|
||
I think the error is introduced on linux by the use of
double fd_copysign(double x, double y)
{
__HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000);
return x;
}
from fdlibm/s_copysign.c
That should be
double fd_copysignLinux (double x, double y) {
__LO(x) = (__LO(x) & 0xFFFFFF7F) | (__LO(y) & 0x80)
return x;
}
on a linux platform (or probably on a x86 linux platform)
Updated•25 years ago
|
Assignee: norris → mccabe
Comment 3•25 years ago
|
||
Mike, can you try out Martin's suggested fix?
Assignee | ||
Comment 4•25 years ago
|
||
(Added Martin Honnen to the CC list.)
Sure enough, the fix works. Thanks!
I'd rather understand a little more about what's going on before I apply it. It
would be better to fix fdlibm to be more xp than to apply a patch that applies
only to linux.
__LO and __HI are defined in fdlibm.h, along with __LITTLE_ENDIAN. Is the
configuration stuff in fdlibm.h broken for linux? Does this effect other OSes?
Is there something we can fix in fdlibm.h?
Mike
Assignee | ||
Comment 5•25 years ago
|
||
Hm. Removing the patch and changing
extern double fd_copysign __P((double, double));
to
#define fd_copysign copysign
in jslibmath.h also seems to fix the problem. But I still wonder if we weren't
using fd_copysign for Linux for other reasons... I'll check in this fix if I
get a chance to run some regression tests.
Mike
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 6•25 years ago
|
||
I ran the javascript regression tests, and it looks like life is better in many
ways if we use the system copy sign rather than fd_copysign from fdlibm for
Linux. Hm. I'd have thought fd_copysign should work for all platforms... maybe
something is wrong about how we define ENDIAN for linux?
I have the fix to jslibmath.h in my tree, and will check in when the tree opens.
Assignee | ||
Updated•25 years ago
|
Target Milestone: M6
Assignee | ||
Comment 7•25 years ago
|
||
I have a fix for this one; waiting for the tree to open for m6.
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 8•25 years ago
|
||
Just checked in a fix to jslibmath.h to use the system copysign instead
fd_copysign for linux. Thanks for spotting this.
Changing component to "Javascript Engine". "Javascript" component is being
retired.
Comment 10•25 years ago
|
||
mike, did this get checked into the tip only? the branch is still broken,
though it's working on the tip
Assignee | ||
Updated•25 years ago
|
Status: REOPENED → RESOLVED
Closed: 25 years ago → 25 years ago
Assignee | ||
Comment 11•25 years ago
|
||
Whoops, looks like I forgot it.
Propagated the change (to jslibmath.h on the tip, 05/04/99 00:12, v. 3.3.) to
SpiderMonkey140_BRANCH. Also cc'ing mang@subcarrier.org.
Comment 12•25 years ago
|
||
thanks!
You need to log in
before you can comment on or make changes to this bug.
Description
•