问题:Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"

原因:18446744073709551615  --有20位,

而long类型的最大长度是: 19位:9223372036854775807

long类型的最大值是9223372036854775807,刚好长度是19个数字

解决:

1.类型换成 float, float的最大值为3.403E38, 也就是3.403*10的38次方,这个长度至少在38位吧,够用了

2.BigInteger. 非基本类型,需要用对应的+-*/方法,如下:

求和:
BigInteger add(BigInteger val) 返回两个大整数的和
求差:
BigInteger subtract(BigInteger val) 返回两个大整数的差
求积:
BigInteger multiply(BigInteger val) 返回两个大整数的积
求商:
BigInteger divide(BigInteger val) 返回两个大整数的商
求模:
BigInteger mod(BigInteger val) 用当前大整数对val求模
求乘方:
BigInteger pow(int exponent) 返回当前大整数的exponent次方
求余:
BigInteger remainder(BigInteger val) 返回当前大整数除以val的余数

类型转换:
double doubleValue() 返回大整数的double类型的值
float floatValue() 返回大整数的float类型的值
long longValue() 返回大整数的long型值
int intValue() 返回大整数的整型值

其它:
BigInteger abs() 返回大整数的绝对值
BigInteger gcd(BigInteger val) 返回大整数的最大公约数
BigInteger max(BigInteger val) 返回两个大整数的最大者
BigInteger min(BigInteger val) 返回两个大整数的最小者
byte[] toByteArray(BigInteger val)将大整数转换成二进制反码保存在byte数组中

详见:https://blog.csdn.net/weixin_40254218/article/details/79474600

3.BigDecimal

BigInteger 任意精度的整数~
可以使用BigDecimal, 支持大整数,浮点运算

long也有限制,不过BigInteger可以存任意大的数

1、有两个类BigInteger和BigDecimal分别表示大整数类和大浮点数类,可以作为比long还要大的数据类型
2、使用字符串或字符串数组、集合等能够存储比long大很多倍的整数变量类型(需数据类型转换)

Java中为什么float型最大值大于long型?
https://blog.csdn.net/u011240877/article/details/47723263

Java中有比long还大的整数类型吗
https://zhidao.baidu.com/question/240285392967051564.html

Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"的更多相关文章

  1. mybatis 报错:Caused by: java.lang.NumberFormatException: For input string

    mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...

  2. MyBatis报错:Caused by: java.lang.NumberFormatException: For input string: "XX"

    <select id="sltTreatment" resultType="com.vitaminmd.sunny.core.bo.Treatment"& ...

  3. 执行Hive时出现org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.NumberFormatException: For input string: "1s"错误的解决办法(图文详解)

    不多说,直接上干货 问题详情 [kfk@bigdata-pro01 apache-hive--bin]$ bin/hive Logging initialized -bin/conf/hive-log ...

  4. Caused by: java.lang.NumberFormatException: For input string: &quot;&quot;

    1.错误描写叙述 java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatEx ...

  5. Caused by: java.lang.NumberFormatException: For input string: " 60"

    原因 原原因:string转int 格式出错 解决:我的输入文件格式在根据“,”分割完之后多出了一个空格,我想要的是“60” 但是分割完之后是“ 60”所以导致格式转换不匹配.

  6. java.lang.NumberFormatException: For input string: "${jdbc.maxActive}"

    一.问题 使用SpringMVC和MyBatis整合,将jdbc配置隔离出来的时候出现下面的错误,百度了很久没有找到解决方法,回家谷歌下,就找到解决方法了,不得不说谷歌就是强大,不废话,下面是具体的错 ...

  7. maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7006@17006"

    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [redis.client ...

  8. Mybatis异常:java.lang.NumberFormatException: For input string: "S"

    MyBatis异常日志如下: Caused by: java.lang.NumberFormatException: For input string: "S" at sun.mi ...

  9. org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NumberFormatException: For input string: "W%" ### Cause: java.lang.NumberFormatException: For input s

    一个常见的myBatis xml文件中的引号错误: org.apache.ibatis.exceptions.PersistenceException: ### Error querying data ...

随机推荐

  1. Git常用命令总结(超实用)【转】

    转自:https://www.linuxprobe.com/git-common-commands.html 本文由LinuxProbe.Com团队成员逄增宝整理发布,原文来自:Linux就这么学. ...

  2. Mysql 5.* 数据库备份及导入

    作者:邓聪聪 倒出数据文件 1) 导出数据和表结构: 进入数据库查看表结构 msql -u用户名 -p密码 msql -u用户名 -p密码 -S /var/lib/mysql/mysql.sock  ...

  3. 设计模式C++学习笔记之十七(Chain of Responsibility责任链模式)

      17.1.解释 概念:使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系.将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它为止. main(),客户 IWom ...

  4. cocos开发插件笔记

    写插件菜单时要注意大小写 { "name": "hello-world", "version": "0.0.1", &q ...

  5. makefile实例

    #.PHONY:cleanall cleanobj cleandiff #cleanall:cleandiff cleanobj # rm program #cleanobj: # rm obj.c ...

  6. List<> of struct with property. Cannot change value of property. why?

    这个返回如下错误:"Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.th ...

  7. js垃圾回收(转

    和C#.Java一样JavaScript有自动垃圾回收机制,也就是说执行环境会负责管理代码执行过程中使用的内存,在开发过程中就无需考虑内存分配及无用内存的回收问题了.JavaScript垃圾回收的机制 ...

  8. dig常用命令

    Dig是域信息搜索器的简称(Domain Information Groper),使用dig命令可以执行查询域名相关的任务. ###1. 理解dig的输出结果 $ dig chenrongrong.i ...

  9. Java中instanceof与getClass的区别

    在比较一个类和另一个类是否属于同一个类实例的时候,通常可以采用instanceof和getClass两种方法比较两者是否相等来判断,但是两者在判断上面是有差别的,下面通过代码说明: public cl ...

  10. 【原创】大叔经验分享(34)hive中文注释乱码

    在hive中查看表结构时中文注释乱码,分为两种情况,一种是desc $table,一种是show create table $table 1 数据库字符集 检查 mysql> show vari ...