-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a better solution #124
Comments
The one thing his does that the above does not do is ... that the number could be typed out. Below might be another possibility.
|
Ew, modulo. If you're going for the better solution use bitwise.
|
Bitwise op cannot be used, for example: isEven(2.2) // true |
Nor can modulo operator be used on floats without doing a bunch of extra steps. Dividing 2.2 by two leaves you with 1.1, which is one with a remainder of some sorts. Not to mention, it seems the general online consensus is that one cannot have an even/odd decimal value. For example 2.3 by our standard rules would be odd, but 2.30 by the standard rules would be even (is the last digit even/odd?). Or whether 2/3 is even/odd (2.66666, last number technically doesnt exist which is undefined, is six which is even, is rounded to 2.67 which is odd if you ignore the fact you can add trailing zeros to make it even, or thought about logically as a fraction which is probably odd). Im not a math expert so who knows how correct that is. |
Arithmetic operations on BigInt and Number will trhow a TypeError. 2n % 2 // Uncaught TypeError: can't convert BigInt to number |
The text was updated successfully, but these errors were encountered: