tags:

views:

174

answers:

3
+2  Q: 

String.format()

"%11.2lf" of C++ is equivalent to ?

You guys have any resource that shows the equivalent formats for both Java and C++?

+2  A: 

C++ cpplusplus.com or MSDN

Java Sun javadocs

Mark
A: 

Boost Format. http://www.boost.org/doc/libs/1%5F37%5F0/libs/format/doc/format.html#syntax

It has the basically the same formatters as printf().
But they are type safe and can be used on streams.

Martin York
I think the OP is looking for the equivalent in Java.
finnw
+1  A: 

Short answer: The Java equivalent is "%11.2f".

In C's printf() (but not scanf()), %f and %lf are equivalent; Both take a double argument.

In Java's Formatter.format(), %f is legal but %lf is not. %f works for Float, Double and BigDecimal values.

finnw