We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

convert 0.00 to 0.0

ellandrd
ellandrd asked
on
Medium Priority
229 Views
Last Modified: 2010-03-31
easy way to do the above?
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
you can't convert it, you instead can display it as 0.00

double d = 0.0;
String converted = new DecimalFormat("0.00").format(d);

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
you will only get the output in the form of String.
if u try to convert it back to double then u will get 0.0

Author

Commented:
yes but it rounds it to 1.3... not really want i wanted...

Commented:
exactly, what do u want ?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
or something like:

NumberFormat nf = new DecimalFormat("0.00");
System.out.println("d="+nf.format(d));

or

System.out.printf("%.2f\n", d);
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
typo in the above

"0.00" should have been "0.0"

and %.2f should have been %.1f

Commented:
> System.out.printf("%.2f\n", d);
do u hav anything called printf in java ?

Author

Commented:
>>exactly, what do u want ?

look here: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21799148.html

closing this thread...

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.