问题
With angular input numbers, I notice that if I enter large numbers they can get rounded to something different.
For example, in this plunkr http://plnkr.co/edit/k5G7eL8gIzWbSPGocdlQ?p=preview I set a large max number like this:
<input type="number" name="input" ng-model="value" min="0" max="9223372036854769" required>
Then, if I enter 9223372036854769 in the input field it gets rounded down one. If I enter 9223372036854767 it gets rounded up one.
Considering only integer numbers (no decimals), what is the maximum integer value inputs can receive without rounding? And what is the minimum?
回答1:
It is not related to angular but more so to JavaScript in which numbers have precision up to 2^53 both positive and negative.
ECMA number spec
回答2:
The value 9223372036854769 is more than Number.MAX_SAFE_INTEGER. A good explanation on your problem can be found in http://www.2ality.com/2013/10/safe-integers.html
来源:https://stackoverflow.com/questions/25918607/what-is-the-max-max-and-min-min-for-angular-form-input-for-integers