Before BigInt, there was asm.js (which automatically handled numbers that were floored with |0 in any operation as integers) and Typed arrays. But other than that, you're right.
|0
automatically handled numbers that were floored with |0
> const value = -1.9; console.log(Math.floor(value)); console.log(Math.trunc(value)); console.log(value | 0); -2 -1 -1
i.e. trunctated, not floored - and that tactic is limited to signed 32 bit values.
Interestingly enough Rescript adopted 32 bit signed integers while TypeScript never bothered with them.
TypedArray/ArrayBuffer/DataView are less about integers and more about a performant means of sharing/moving binary data between execution contexts.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Before BigInt, there was asm.js (which automatically handled numbers that were floored with
|0
in any operation as integers) and Typed arrays. But other than that, you're right.i.e. trunctated, not floored - and that tactic is limited to signed 32 bit values.
Interestingly enough Rescript adopted 32 bit signed integers while TypeScript never bothered with them.
TypedArray/ArrayBuffer/DataView are less about integers and more about a performant means of sharing/moving binary data between execution contexts.