输入大数以避免NumberFormatException [英] Input of big number to avoid NumberFormatException

查看:180
本文介绍了输入大数以避免NumberFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须控制1到9999999999之间的输入(表示学校的注册号)
原始类型long只能容纳大约2.000.000.000,我该如何存储这个大小的数字?

I have to control input from 1 to 9999999999 (that represents the registration number of school) The primitive type long can only hold up to about 2.000.000.000, how can i store numbers of this size?

推荐答案

根据这个 long 数据类型可以使用64位保存从-9,223,372,036,854,775,808到9,223,372,036,854,775,807的值。它应该能够容纳9,999,999,999。您确定在所有地方都将该值视为 long 吗?

According to this, the long data type can hold values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, using 64 bits. It should be able to hold 9,999,999,999. Are you sure that you are treating that value as a long in all places?

这篇关于输入大数以避免NumberFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆