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
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Beginning Java
Double Value
Natraj Gudla
Ranch Hand
Posts: 34
posted 19 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: 24204
44
I like...
posted 19 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]
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
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...