Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

conversion of 1.0000000000005117E-4 to 0.00001

 
Gowrishankar Mudaliar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am having a program like this.


It evaluates an expression like " 1.00*(100-99.99)/100 ".
The result is a number in exponential format. But i only want a number in normal format. Is there a way i can achieve this straight forwardly.

public class ATLDiscount
{
public static void main(String ar[]) throws ParseException
{
double dIntermediateCalcCost = 0,dPrice = 0,dVal = 0;

dPrice = 1.00;
dVal= 99.99;

dIntermediateCalcCost = dPrice*(100-dVal)/100;

System.out.println("Intermediate COst double..:"+dIntermediateCalcCost);



}
}

Thanks
Gowri
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java.text.DecimalFormat.



This isn't an advanced question; I'm moving this to JiG(Intermediate).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic