问题: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. css干货部分

    1.css的引入方式(三种): a.行内样式<div> <p style="color: green">我是一个段落</p> </div& ...

  2. MySQL主从复制故障1595报错【原创】

    服务器环境 架构图 架构搭成后,在B机器上发现主从报错Last_IO_Errno: 1595 Last_IO_Error: Relay log write failure: could not que ...

  3. vc++高级班之多线程篇[7]---线程间的同步机制②

    //示例代码: CStringArray g_ArrString; UINT __cdecl ThreadProc(LPVOID lpParameter) {  int startIdx = (int ...

  4. jquery iCheck的全选和获取value

    jQuery iCheck 插件提供高度可定制的复选框和单选按钮(jQuery和Zepto).最新版本1.0.2,有个最新的2.0预览版,但是发布之后没有再更新. 特点:在不同的浏览器和设备(桌面和移 ...

  5. 使用openssl命令制作ecc证书

    # openssl ecparam -out EccCA.key -name prime256v1 -genkey # openssl req -config openssl.cnf -key Ecc ...

  6. luci 中require函数包含的路径

    在 lua 脚本中常用的包含某个文件就是 require 函数. 例如: #!/usr/bin/lua                     // 表明使用的是lua脚本,像shell脚本一样 lo ...

  7. POJ 1659

    题意: 给你一个数列, 判断是否可以构成一个图, 可以则输出 构成图的一种方式 构图根据 Havel-Hakimi定理来构图 (在排序的时候注意 节点下标会变化, 故用结构体) #include< ...

  8. 【原创】大数据基础之Benchmark(4)TPC-DS测试结果(hive/hive on spark/spark sql/impala/presto)

    1 测试集群 内存:256GCPU:32Core (Intel(R) Xeon(R) CPU E5-2640 v3 @ 2.60GHz)Disk(系统盘):300GDisk(数据盘):1.5T*1 2 ...

  9. [javascript]XMLHttpRequest GET/SET HTTP头与改变HTTP METHOD示例代码

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. swift 实践- 05 -- UITextField

    import UIKit class ViewController: UIViewController ,UITextFieldDelegate{ // 文本框的创建, 有如下几个样式: // UIT ...