-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat integers longer than 32 bit as floats. (#6082)
* Fix handling of integers longer than 32 bits. Treat them as floats. * Fix handling of integers longer than 32 bits. Treat them as floats. * Added tests for number type inference.
- Loading branch information
1 parent
bb1d429
commit e117179
Showing
8 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const is32BitInteger = require(`../is-32-bit-integer.js`) | ||
|
||
const MAX_INT = 2147483647 | ||
const MIN_INT = -2147483648 | ||
|
||
describe(`is32BitInteger`, () => { | ||
it(`works with all kind of values`, () => { | ||
expect(is32BitInteger(MAX_INT)).toBe(true) | ||
expect(is32BitInteger(MIN_INT)).toBe(true) | ||
expect(is32BitInteger(MAX_INT + 1)).toBe(false) | ||
expect(is32BitInteger(MIN_INT - 1)).toBe(false) | ||
expect(is32BitInteger(2.4)).toBe(false) | ||
expect(is32BitInteger(`42`)).toBe(false) | ||
expect(is32BitInteger({})).toBe(false) | ||
expect(is32BitInteger([1])).toBe(false) | ||
expect(is32BitInteger(true)).toBe(false) | ||
expect(is32BitInteger(false)).toBe(false) | ||
expect(is32BitInteger(undefined)).toBe(false) | ||
expect(is32BitInteger(null)).toBe(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(x) { | ||
return (x | 0) === x | ||
} |