C++相当于 Java 中 String.format() 的 %ld
例如,C++ 中的 %11.2lf
在 Java 中变为 %11.2f
。 长格式怎么样?
For instance, %11.2lf
in C++ becomes %11.2f
in Java.
How about for long format?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您可能已经发现的那样,没有必要指定
l
标志。根据 文档,十进制整数由d
指定,就像在 C++ 中一样。所以答案就是%d
。As you may have worked out, it's not necessary to specify the
l
flag. According to the docs, a decimal integer is specified byd
just like in C++. So the answer is just%d
.使用
%d
表示小数(long、int)。工作正常。例如:...打印得很好。阅读
java.util .Formatter
了解更多详细信息。%d
将需要long
,没问题。Use
%d
for decimals (long, int). It works OK. E.g.:...will print just fine. Read up on
java.util.Formatter
for more details.%d
will take along
, no problem.