Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

zero suppression? 1

Status
Not open for further replies.

snotmare

Programmer
Jan 15, 2004
262
US
Greetings!

I have the following numbers...

10.45
0.3
0.00

... that I'd like to display like this...

10.45
.3
.00

What is the best way to do this besides using string functions? I'm already using BigDecimal's setScale() method to round the decimals, but now I'd like to get rid of leading zeros.

Any ideas?


---------------------
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Take a look at the DecimalFormat class. I did this for a class once.

"If you say you can, or you say you can't, you're right!"
-- Henry Ford
 
Excellent, thanks!


---------------------
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top