加入收藏 | 设为首页 | 会员中心 | 我要投稿 莱芜站长网 (https://www.0634zz.com/)- 云连接、建站、智能边缘云、设备管理、大数据!
当前位置: 首页 > 编程开发 > Java > 正文

java – 如何使用输入大小修饰符打印一个长类型值?

发布时间:2020-07-23 22:08:46 所属栏目:Java 来源:互联网
导读:这基本上是我想做的 // ... some code, calculations, what have you ...long timeToAdd = returnTimeToAddInLongFormat();// lets output the long type now, and yes i need the width and precision.System.out.printf

这基本上是我想做的

// ... some code,calculations,what have you ...
long timeToAdd = returnTimeToAddInLongFormat();

// lets output the long type now,and yes i need the width and precision.
System.out.printf("Time to add: %13.10ld",timeToAdd);

我已经阅读了关于这个主题的大部分google搜索,并且认为我理解如何在概念上做到这一点,但是JRE会给我一个UnknownFormatConversionException,并告诉我我的输入大小修改器l不工作.

还有另一种做法吗,还是想念小东西?

解决方法

Java将所有整数值视为d,没有ld.偶数字节和BigInteger是d类型.它也假定整数没有小数位.如果要显示10个零,则可以先转换为双倍,然后使用f

(编辑:莱芜站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读