I looked at this question on how to effectively check if a value is an integer. One answer is recommended n === (n|0)for quick rounding using an operator |. On a whim, I decided to test it with Number.MAX_VALUE. Despite the fact that it should be an integer (I think?), The Test returned with an error.
n === (n|0)
|
Number.MAX_VALUE
It also returned to false for Number.MAX_SAFE_INTEGER, so I decided to check out some other large numbers and found the following:
Number.MAX_SAFE_INTEGER
Number.MAX_VALUE | 0 --> 0 Number.MAX_SAFE_INTEGER | 0 --> -1 Number.MAX_SAFE_INTEGER/2 | 0 --> -1 Number.MAX_SAFE_INTEGER/8 | 0 --> -1 1234567890 | 0 --> 1234567890
I'm not sure what the operator |does internally, but MAX_SAFE_INTEGERdoes not seem safe. Why is this so?
MAX_SAFE_INTEGER
, MAX_SAFE_INTEGER ... float , .. 53 .
, 32- .
, , ;)
| JavaScript 32- , . |0 , , JavaScript 32- ( , int C , , ).
|0
int
, Number.MAX_SAFE_INTEGER ; IE, undefined, , , , , , 32 , double ( ): 2 ^ 32- 1, 4 32 - . , | /signed/number, 31 . .
double
( , ), , . 0001, 1110 + 1 == 1111 (, 32 , ), , .
Source: https://habr.com/ru/post/1536811/More articles:How to pass session id as part of a Soap request? - javaHow to separate Rails Rails tests that make api calls - apiPython Beautiful Soup 'NoneType' object error - pythonPython ambiguous words - pythonWhy does Doxygen group enumerations of the same name from different C files? - cDoxygen C # XML Comments: Multiply enum with the same name and different scope combined? - c #PHP observer pattern - good practice for different events - oopCustom UITableViewHeaderFooterView with XIB and AutoLayout - iosAdding X-WR-CALNAME to DDay.iCal.iCalendar.Calendar - icalendarCan we set the opacity of the background image of the panel? - c #All Articles