问题: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. 修改Spring Social默认提交地址

    ⒈ package cn.coreqi.social.config; import org.springframework.social.security.SocialAuthenticationFi ...

  2. 如何生成添加前缀的顺序DIV

    今天我们这边的需求是生产类似于 div1 div2 div3 这种的方式. filters: { pre: function (value) { return 'div' + value; } }, ...

  3. IPC$横向渗透代码实现

    思路 IPC$横向渗透的方法,也是病毒常用的扩散方法. 1.建立连接 2.复制文件到共享中C$.D$.E$.F$ 3.获取服务器的时间 3.设定计划任务按时间执行 用到的Windows API 建立网 ...

  4. CentOS6源码安装VSFTPD3

    还是碰到老问题:安全扫描,由于CentOS6上VSFTPD最高支持到V2.2.2,目前已经是官方支持的最新版本(发布了几年...) 但有安全漏洞,又没法通过限制访问进行控制,只能想办法升级到最新版本了 ...

  5. UniGUI 如何进行 UniDBGrid 的单元 Cell 的计算 ?

    来源:http://forums.unigui.com/index.php?/topic/10508-update-dataset-events-in-unidbgrid/?hl=unidbgrid ...

  6. 红迅JSAAS敏捷开发平台

    红迅JSAAS敏捷开发平台:    http://www.redxun.cn/

  7. requests支持socks5代理了

    记录下 以前: import socket import socks from requests_html import HTMLSession session=HTMLSession() socks ...

  8. Windows登录类型及安全日志解析

    Windows登录类型及安全日志解析 一.Windows登录类型 如果你留意Windows系统的安全日志,在那些事件描述中你将会发现里面的“登录类型”并非全部相同,难道除了在键盘上进行交互式登录(登录 ...

  9. applet jre冲突问题

    erp中用到applet,jre为1.6,开发用到jdk1.8,有冲突 安装jre1.6,再安装jdk8,将jdk1.8文件夹复制后卸载1.8,然后重新黏贴,将javahome定向到1.8文件夹

  10. QTableWidget

    1.QTableWidget继承自QTableView. QSqlTableModel能与QTableView绑定,但不能于QTableWidget绑定.​ QTableWidget是QTableVi ...