| Author |
printf and floating point
|
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
System.out.printf("%f", Math.PI);
Output: 3,141593
So is default: System.out.printf("%.6f", Math.PI); ?
|
SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
|
 |
Charles Chikito
Ranch Hand
Joined: May 22, 2009
Posts: 76
|
|
I guess so. My compiler did produced the same output but with a decimal point instead of a comma.
_Charles
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
Dot instead of comma - it is local dependent. printf method takes default Locale.
But 6 fraction digits are disguising - NumberFormat object uses 3 fraction digits by default
|
 |
 |
|
|
subject: printf and floating point
|
|
|