Closed Bug 2314 Opened 26 years ago Closed 26 years ago

Javascript parseInt()

Categories

(Core :: JavaScript Engine, defect, P2)

x86
Windows 95
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: paulmac, Assigned: fur)

Details

Copied from Bugsplat #330172 -------------------------------------------------------------------- Here is the problem which i found in the parseInt function of javascript . Expression Return Value Expected Value ---------- ------------- -------------- parseInt(15/12) 1 1 parseInt(12/15) NaN 0 parseInt(1/11) 0 0 If we do parseInt(a/b) where a/b is less than 1/10 , the return value is zero as expected but if a/b lies in between 1/10 and 1 , the return value in NaN rather than zero .
Summary: Javascript parseInt()
FYI, parseInt is for parsing integers, but you are passing in floating-point values, so parseInt ends up examining the prefix of the passed in value that looks like an integer. Still, the described behavior does not look correct. However, if I pull and build the JS shell, I don't see the behavior that you describe. Are you sure that this bug applies to Mozilla and not some 4.x browser ?
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Actually, I was lame and didn't check it with Mozilla. I assumed Javascript had not changed from 4.x. I will take your word for it and mark it resolved. Thanks!
Status: RESOLVED → VERIFIED
Changing component to "Javascript Engine". "Javascript" component is being retired.
You need to log in before you can comment on or make changes to this bug.