| Author |
formatting using printf
|
P Teng
Greenhorn
Joined: Nov 20, 2009
Posts: 16
|
|
Can some one please explain the output caused by line 1
output is below. What causes 559998 to appear after the . instead of just 56
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
The way floating point numbers are handled on computers. In short, just like you can't represent 1/3 exactly in decimal (0.3333 is an approximation), you can't represent 0.56 or even 0.1 exactly in binary. See this.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: formatting using printf
|
|
|