aspose file tools*
The moose likes Java in General and the fly likes how to display decimal point Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to display decimal point" Watch "how to display decimal point" New topic
Author

how to display decimal point

debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

hi all,

i need to display the decimal / fractions, but not getting it, when i have

output is :


all i need to display like


i can not use this code to display because it returns string


any help would be appreciated
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

debraj mallick wrote:i can not use this code to display because it returns string

What do you mean? If you want to display a number, it must be converted to a string somehow. There's no way around that. The question is how you get the string formatted the way you want.

If you want it with 4 decimal places, then specify that in your DecimalFormat:

An alternative is:


Is there a reason why you are using Double (the wrapper class) instead of double (the primitive type)? If not, then prefer double instead of Double.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

Thankyou Jesper de Jong
 
wood burning stoves
 
subject: how to display decimal point