Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Beginning Java
Double Value
Natraj Gudla
Ranch Hand
Posts: 34
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I have a double value which prints a lot of digits after the decimal.
how do i control the number of digits after the decimal.
regards
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You can use the java.text.DecimalFormat class to prepare formatted Strings from your double value -- i.e.,
DecimalFormat df = new DecimalFormat("0.000"); System.out.println(df.format(123.456789));
prints 123.456 .
[Jess in Action]
[AskingGoodQuestions]
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Convert double (primitive) value to String
printf question
How to count the number of digits after decimal point in java?
How to identify double length
Multiplying double values
More...