Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"
问题: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"的更多相关文章
- mybatis 报错:Caused by: java.lang.NumberFormatException: For input string
mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...
- MyBatis报错:Caused by: java.lang.NumberFormatException: For input string: "XX"
<select id="sltTreatment" resultType="com.vitaminmd.sunny.core.bo.Treatment"& ...
- 执行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 ...
- Caused by: java.lang.NumberFormatException: For input string: ""
1.错误描写叙述 java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatEx ...
- Caused by: java.lang.NumberFormatException: For input string: " 60"
原因 原原因:string转int 格式出错 解决:我的输入文件格式在根据“,”分割完之后多出了一个空格,我想要的是“60” 但是分割完之后是“ 60”所以导致格式转换不匹配.
- java.lang.NumberFormatException: For input string: "${jdbc.maxActive}"
一.问题 使用SpringMVC和MyBatis整合,将jdbc配置隔离出来的时候出现下面的错误,百度了很久没有找到解决方法,回家谷歌下,就找到解决方法了,不得不说谷歌就是强大,不废话,下面是具体的错 ...
- maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7006@17006"
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [redis.client ...
- Mybatis异常:java.lang.NumberFormatException: For input string: "S"
MyBatis异常日志如下: Caused by: java.lang.NumberFormatException: For input string: "S" at sun.mi ...
- 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 ...
随机推荐
- python使用PDB进行调试
参考链接:https://www.cnblogs.com/xiaohai2003ly/p/8529472.html 调入包:import pdb 调试时的一些命令: (1)p 变量名:查看变量:(p ...
- shell-自动按省市建立文件夹,并在每个城市下创建当前日期文件夹
Code: #!/bin/bash date=`date +%Y%m%d` ProName="广东市" CityName="广州市 汕尾市 阳江市 揭阳市 茂名市 江门市 ...
- java官网真不错
要用到一个软件,打开时说没找到javaw,然后大家说这是因为没安装java,就按着链接去了java官网 https://www.java.com/zh_CN/download/faq/remove_o ...
- 解决:fatal error LNK1104: 无法打开文件“libc.lib”
今天使用VS2017编译比较老的VC++项目,出现了[fatal error LNK1104: 无法打开文件“libc.lib”]的链接器问题,解决方法如下: 项目->属性中->配置属性- ...
- Java 处理 XML
DOM 优缺点:实现 W3C 标准,有多种编程语言支持这种解析方式,并且这种方法本身操作上简单快捷,十分易于初学者掌握.其处理方式是将 XML 整个作为类似树结构的方式读入内存中以便操作及解析,因此支 ...
- 使用lld自动发现监控多实例redis
zabbix 可以通过常见的手段监控到各种服务,通过编写脚本来获取返回值并将获取到的值通过图形来展现出来,包括(系统.服务.业务)层面.可是有些时候在一些不固定的场合监控一些不固定的服务就比较麻烦.例 ...
- WebApi中使用session
webapi默认是不支持session的,要通过一些手动配置来开启Session功能 在Global.asax里添加: 导入命名空间: using System.Web.SessionState; p ...
- spring中BeanFactory和FactoryBean的区别
共同点: 都是接口 区别: BeanFactory 以Factory结尾,表示它是一个工厂类,用于管理Bean的一个工厂 在Spring中,所有的Bean都是由BeanFactory(也就是IOC容器 ...
- 判断js数据类型的四种方法,以及各自的优缺点(转)
转载地址:https://blog.csdn.net/lhjuejiang/article/details/79623973 数据类型分为基本类型和引用类型: 基本类型:String.Number.B ...
- PID控制器开发笔记之九:基于前馈补偿的PID控制器的实现
对于一般的时滞系统来说,设定值的变动会产生较大的滞后才能反映在被控变量上,从而产生合理的调节.而前馈控制系统是根据扰动或给定值的变化按补偿原理来工作的控制系统,其特点是当扰动产生后,被控变量还未变化以 ...