The Artima Developer Community
Sponsored Link

Java Answers Forum
change the point: 3.388443E-4 --> 0,0003388

1 reply on 1 page. Most recent reply: Jun 22, 2003 11:28 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
jarvis Cocker

Posts: 1
Nickname: jarvis19
Registered: Jun, 2003

change the point: 3.388443E-4 --> 0,0003388 Posted: Jun 22, 2003 5:25 AM
Reply to this message Reply
Advertisement
how can I change the point?

I´ve got the following method to calculate 10^(-3,46)

public double AP1 (double S1)
{
double s = 123 - S1;
int f = 5;
double c = ((s/20) - (92.4/20) - f);
double base = 10;
double distanz = Math.pow(base, c);
System.out.println(s + " " + c);
return distanz;

}

the output is 3.3884415613920273E-4
but do I have to change that the output is without E-4 like 0,000338844156

??


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: change the point: 3.388443E-4 --> 0,0003388 Posted: Jun 22, 2003 11:28 PM
Reply to this message Reply
Look at the NumberFormat and DecimalFormat classes. I haven't fooled with these much, but I think you may need to cast the NumberFormat object you get from getInstance() to a DecimalFormat if you want to preserve locale-specific information.

Here's a simple example of just DecimalFormat alone:
System.out.println( new DecimalFormat("#.#######").format( 0.00002 ) );

Flat View: This topic has 1 reply on 1 page
Topic: Need help in optimisation. Previous Topic   Next Topic Topic: Applet Servlet communication

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use