wtfjs | It has never been easier to contribute a wtf to wtfjs
kandi X-RAY | wtfjs Summary
kandi X-RAY | wtfjs Summary
It has never been easier to contribute a wtf to wtfjs.com!.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of wtfjs
wtfjs Key Features
wtfjs Examples and Code Snippets
Community Discussions
Trending Discussions on wtfjs
QUESTION
I was working with some validation that it was supposed to allow integers only, I had something like this:
...ANSWER
Answered 2021-May-04 at 07:11The Javascript standard is actually very clear about the difference between "mathematical values" and Numbers
as represented in the language (https://262.ecma-international.org/11.0/#sec-mathematical-operations)
From the mathematical standpoint, 100.0
is definitely an integer. From the JS standpoint, isInteger(100.0)
is true
, because isInteger
is defined to return true
for Numbers
whose mathematical value is integer.
Your uncertainty comes from the fact in some other languages 100
and 100.0
are indeed quite different things, with different storage mechanisms and the nature of operations performed on them. In Javascript, we actually don't know how a particular number is stored, and have no control over that. The standard says that all Numbers
should behave as if they all were IEEE 754-2019 double values, but what sequence of operations a particular engine actually performs when you compute 1+2
and how they are different from 1.2+3.4
is up to that engine.
QUESTION
In this code from wtfjs, apparently something goes wrong.
...ANSWER
Answered 2018-Feb-23 at 14:01Can anyone specify why this happens?
11111111111111111
is greater than Number.MAX_SAFE_INTEGER, hence it is unsafe for any numerical-operation or comparison.
As mentioned in the doc
Number.MAX_SAFE_INTEGER + 1
===Number.MAX_SAFE_INTEGER + 2
evaluates totrue
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wtfjs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page