formatting and converting in java
Posted
by mike_hornbeck
on Stack Overflow
See other posts from Stack Overflow
or by mike_hornbeck
Published on 2010-03-27T16:51:16Z
Indexed on
2010/03/27
16:53 UTC
Read the original article
Hit count: 138
I have few small basic problems :
How to format :
int i = 456;
to give output :
""00000456"
? I've tried %08d but it's not working. Next thing is a problem with conversion and then formatting. I have side and height of triangle, let's say int's 4,7, and 7 is the height. From formula for field we know that F=1/2(a*h). So how to get F as float, with precision up to 10 places ?
float f = a*h;
works fine, but multiplying it by 0.5 gives error and by 1/2 returns 0.
© Stack Overflow or respective owner