java开发中需要将16进制转为浮点数,但是下面的方法有区别吗?
伊谢尔伦
伊谢尔伦 2017-04-17 13:25:01
[Java讨论组]

【java 中这两个方法区别在哪里?只是转数据的时候的范围问题吗?】integer.parseint() 与Long.parselong()的区别
在开发中碰到前者在我的机器上能运行,但是到了客户的机器上就不能正常运行了,换成后者的方法就可以了,为什么?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
PHP中文网

参考API Specification,看看是不是以下情况。

An exception of type NumberFormatException is thrown if any of the following situations occurs:

  • The first argument is null or is a string of length zero.
  • The radix is either smaller than Character.MIN_RADIX or larger than Character.MAX_RADIX.
  • Any character of the string is not a digit of the specified radix, except that the first character may be a minus sign '-' ('\u002D') or plus sign '+' ('\u002B') provided that the string is longer than length 1.
  • The value represented by the string is not a value of type int.

或者说Integer.MAX_VALUE是2147483647,Integer.parseInt会将字符串解析为有符号整型,但如果要转比如F0F0F0F0,超出范围就没得搞。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号