File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 14432
    
  23

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 8 API documentation
debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

Thankyou Jesper de Jong
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to display decimal point