Opened 9 years ago
Closed 9 years ago
#15100 closed bug (fixed)
isNumeric implementation of version 2.1.0 returns wrong results in Opera 12.17
Reported by: | PachaG | Owned by: | gibson042 |
---|---|---|---|
Priority: | high | Milestone: | 1.12/2.2 |
Component: | core | Version: | 2.1.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The isNumeric function of older (2.0.3) versions works correctly in Opera 12.17
$.isNumeric(1.5999999999999999) == false $.isNumeric(1.59999) == true
The test page http://jsfiddle.net/z2NYD/
Change History (3)
comment:1 Changed 9 years ago by
Component: | unfiled → core |
---|---|
Milestone: | None → 1.12/2.2 |
Priority: | undecided → high |
Status: | new → open |
comment:2 Changed 9 years ago by
Owner: | set to gibson042 |
---|---|
Status: | open → assigned |
Looks like it's from loss of precision in a string cast for parseFloat
... the fix will be almost certainly be replacing obj - parseFloat( obj ) >= 0
with !isNaN( obj - parseFloat( obj ) )
.
comment:3 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Core: Work around loss of precision from parseFloat
Fixes #15100 (cherry picked from commit b6e99eb43c35a3cd048c5c56d31c7e871f299a77)
Changeset: e1192af8726bcd25da58aba64b20d89e919230b9
Note: See
TracTickets for help on using
tickets.
Probably this commit: https://github.com/jquery/jquery/commit/68213f20bb5d5426f99bafde028ecab601a9d105
My guess is that since we're dealing with floating point the result ends up being ever-so-slightly negative. I just need to find an Opera 12.17 to prove it.
@gibson042 what do you think?