Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

convert 0.00 to 0.0

easy way to do the above?
0
ellandrd
Asked:
ellandrd
  • 3
  • 3
  • 2
4 Solutions
 
objectsCommented:
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);
0
 
avinthmCommented:
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
0
 
ellandrdAuthor Commented:
yes but it rounds it to 1.3... not really want i wanted...

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
avinthmCommented:
exactly, what do u want ?
0
 
objectsCommented:
or something like:

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

or

System.out.printf("%.2f\n", d);
0
 
objectsCommented:
typo in the above

"0.00" should have been "0.0"

and %.2f should have been %.1f
0
 
avinthmCommented:
> System.out.printf("%.2f\n", d);
do u hav anything called printf in java ?
0
 
ellandrdAuthor Commented:
>>exactly, what do u want ?

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

closing this thread...

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now