Closed
Bug 688744
Opened 13 years ago
Closed 13 years ago
float modulo incorrectly produces the same result as double modulo
Categories
(Tamarin Graveyard :: Virtual Machine, defect)
Tamarin Graveyard
Virtual Machine
Tracking
(Not tracked)
VERIFIED
WONTFIX
People
(Reporter: brbaker, Unassigned)
References
Details
f1%f2 == Number(f1)%Number(f2) this should not be true since the float modulo should happen in single precision, which should produce worse precision than the double modulo which should happen in double precision, so the results of the 2 should NOT be equal.
Flags: in-testsuite+
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
Flags: flashplayer-bug-
Reporter | ||
Comment 1•13 years ago
|
||
Comments from Virgil: modulo on float & number should THEORETICALLY yield different results. However, on gcc & VisualC (windows/x86), fmod seems to return identical results with fmodf if the input values are identical (and no, I didn't get fooled by the "fmod" version with float arguments - I explicitly casted the parameters to double). I suspect the runtime library implementations perform both operations on 64 bits. The thing is, there's no hardware instruction for modulo - except the x87 FPU (it has a "FPREM" instruction). Bottom line is - the C runtimelibrary makes no diffeernce (not on x86 and x64, Mac/Win, at least)
Reporter | ||
Comment 2•13 years ago
|
||
Virgil -> QRB: We could theoretically fix it by implementing our own modulo, but.... probably not worth the effort
Comment 3•13 years ago
|
||
Brent, what are the inputs you have asumed here (the values of f1 and f2)?
Reporter | ||
Comment 4•13 years ago
|
||
(In reply to Lars T Hansen from comment #3) > Brent, what are the inputs you have asumed here (the values of f1 and f2)? var f1:float = 1.2345678e9; var f2:float = 6.543210987;
Comment 5•13 years ago
|
||
f1 % f2 must have run-time type "float" though, it must never have run-time type "Number". I think we can live with the computation being slow (we already have a bug open on % being slow in general but that's worse for Number than for float) and being performed in the Number domain, as long as the result is of type float. I should probably add appropriate language to the spec about this. I will file a bug. If we ever end up with a proper float modulo then this is a pretty easy thing to add a versioned fix for.
Reporter | ||
Comment 6•13 years ago
|
||
Closing as NAB. ABC Extensions spec (draft 5) states that Float modulo can operate in double precision 6.1 Float: Float modulo may operate with double precision. Note: It appears that most C/C++ run-time libraries implement float modulo (fmodf) on top of the double modulo method (fmod), possibly because FPUs only support the latter.
Status: NEW → RESOLVED
Closed: 13 years ago
Flags: flashplayer-qrb? → flashplayer-qrb+
Resolution: --- → WONTFIX
Reporter | ||
Updated•13 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•