turning double into percent values..

let's say i have a double value like this0.05989773557341125i want to turn it into a percentagei tried:int percent = (int) number*100;but it doesn't work and a zero comes out of it
[224 byte] By [Nihcolasa] at [2007-11-27 9:08:44]
# 1

int percent = (int) number*100;

That casts number to an int (which rounds it down to 0) then multiplies it by 100.

int percent = (int) (number*100.0);

That does the multiplication on floating point types, then casts the result to an int, truncating the decimal part.

hunter9000a at 2007-7-12 21:47:29 > top of Java-index,Java Essentials,Java Programming...
# 2
If it's for display purposes, look at NumberFormat.getPercentInstance().
OleVVa at 2007-7-12 21:47:29 > top of Java-index,Java Essentials,Java Programming...
# 3
OP, you're having a great deal of trouble with your int casts, I see: http://forum.java.sun.com/thread.jspa?threadID=5189749&messageID=9742619#9742619Best to review this in a java book.
petes1234a at 2007-7-12 21:47:29 > top of Java-index,Java Essentials,Java Programming...