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
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Decimal Alignment
Timothy Leong
Ranch Hand
Posts: 55
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Dear all,
I have the following numbers
1.2 5.6
62.4 87.2
how do i align to become
1.2 5.6
62.4 87.2
soo tt the decimal symbols are aligned?
thanks
Timothy Leong
Ranch Hand
Posts: 55
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think my additional spaces get removed
should be like this
#1.2 #5.6
62.4 87.2
thanks
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use java.text.DecimalFormat to format them. In
Java
5, you could also use the new Formatter capability; see System.out.printf().
[Jess in Action]
[AskingGoodQuestions]
Manuel Moons
Ranch Hand
Posts: 229
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Using the # will indeed leave out 0.
The format you want to use is something like this #0.00
Look at the explanation of the
pattern
in the javadoc
DecimalFormat javadoc
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Math.round() question
Is there a jquery equivalent to python’s “sum” built-in function?
Formatting strings as money format
are there anybody know how to use WSDD to run a pocket PC emulator
Sorting java.lang.objects
More...