Skip to content
Advertisement

Tag: formatter

What is the Java equivalent of C’s printf %g format specifier?

I tried using Formatter.format, but that seems to leave the mantissa on numbers with 0 mantissa, whereas the C version does not. Is there an equivalent of C’s %g format specifier in Java, and if not, is there a way to fake it? My intention is to preserve the mantissa exactly like C’s for compatibility reasons. foo.c Main.java Console: Similarly,

Advertisement