What is the max max and min min for angular form input for integers?

落爺英雄遲暮 提交于 2021-01-03 08:42:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!