printf的:在Java的和C的实现差异 [英] Printf: differences in Java's and C's implementation

查看:140
本文介绍了printf的:在Java的和C的实现差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我不能用我注意到 * 来的宽度或precision参数传递给Java的实施的printf

I noticed today that I can't use * to pass width or precision arguments to Java's implementation of printf.

也就是说,以下参数的printf 是有效的在C,而不是Java:

That is, the following arguments to printf are valid in C, but not Java:

"%*d", 10, 3
"%-*d", 10, 3
"%0*d", 10, 3
"%*.5f", 11, 1.0/9
"%-11.*f", 5, 1.0/9
"%0*.*f", 11, 5, 1.0/9

是否有任何其他实现差异我应该知道的?

Are there any other implementation differences I should be aware of?

推荐答案

我不认为它是差异。我想通过 Java文档仔细,仅读和完全由去那。在不同角度思考是可能导致事情漏网。

I wouldn't think of it as differences. I'd just read through the Java documentation carefully and go entirely from that. Thinking in terms of differences is likely to lead to things slipping through the net.

在换句话说,我想对待的相似的为巧合,并承担了两者不同的是,直到证明并非如此:)

In other words, I'd treat the similarities as coincidences, and assume the two are different until proven otherwise :)

这篇关于printf的:在Java的和C的实现差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆