问题: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. 使用@Valid和BindingResult验证请求参数的合法性并处理校验结果

    /** * 添加用户,使用@RequestBody将请求体映射到Action方法参数中 * 使用@Valid注解验证请求参数的合法性 * 使用BindingResult处理校验结果 * @param ...

  2. SpringBoot单元测试示例

    ⒈控制器Action示例 package cn.coreqi.controller; import org.junit.Test; import org.junit.runner.RunWith; i ...

  3. A Light CNN for Deep Face Representation with Noisy Labels

    承接上一篇博客.该论文思路清晰,实验充分,这里大致写一些比较不错的idea.从标题就能看出本文的主要贡献:轻量.鲁棒.利用一个轻量CNN从大规模数据且含大量噪声中来学习一个深度面部表征. 直接谈谈贡献 ...

  4. LwIP Application Developers Manual9---LwIP and multithreading

    1.前言 lwIP的内核并不是线程安全的.如果我们必须在多线程环境里使用lwIP,那么我们必须使用“upper”API层的函数(netconn或sockets).当使用raw API时,你需要自己保护 ...

  5. eMMC基础技术4:eMMC command

    1.前言 本文主要对eMMC的command进行详细介绍,主要包含如下内容: (1)command类型 (2)command格式 2.command类型 command类型 说明 bc 不带respo ...

  6. Delphi 的 FireDAC 连接管理与配置过程

    Delphi 的 FireDAC 连接管理与配置过程: 使用 FireDAC 技术连接 数据库,主要是使用  TFDConnection ,其中有一参数是选择  ConnectionDefFile. ...

  7. 链接器link.exe 编译器cl.exe 资源编译器rc.exe

    原文地址:https://blog.csdn.net/biggbang/article/details/24433065 1.cl.exe文件是Visual C\C++的编译器,它将程序源代码文件编译 ...

  8. Scientific Toolworks Understand

    Scientific Toolworks Understand是一款定位于代码阅读的软件.界面用Qt开发的. 软件特性: 1.支持多语言:Ada, C, C++, C#, Java, FORTRAN, ...

  9. telnet mysql时出现:is not allowed to connect to this MySQL serverConnection closed by foreign host问题的解决

    有时候telnet一个mysql服务器的时候会出现: Host '192.168.0.1' is not allowed to connect to this MySQL serverConnecti ...

  10. 【shell】两种字符串提取场景的实现

    shell虽然比batch顺眼点儿,但还是老话,入门容易,精通难. 1.场景一是这样的,现有字符串的内容 name: tiger; age:18; location:china; 需求:提取每个属性的 ...