Formatting a number, placing the decimal in the proper place

B

BoomerangThree

Can someone help me out on formatting a number and getting the decimal in
the right place?

1) I have the number 8883.
2) I would like to format the number so it shows up as 88.33.

Thanks for any support, past, present, and future...
 
A

Andrew Thompson

On Thu, 19 Aug 2004 21:43:15 -0400, BoomerangThree wrote:

Hi BoomerangThree..

Is there some more significance to that name?

The 'Boomerang', I understand, since I have
already seen this exact same post on
c.l.j.help, more commonly referred to
'round here as multi-posting, further details..
<http://www.physci.org/codes/javafaq.jsp#xpost>

BTW, Please don't (multi-post).

No, what *I* was wondering about your name is,
...does the 'Three' mean I am about to see this
same post in a *third* group?

I recommend you restrict your posts to c.l.j.help
for the time being, and you might want to zip on
back and ensure that you make your expected inputs
and outputs clear..
 
J

Jacob

BoomerangThree said:
Can someone help me out on formatting a number and getting the decimal in
the right place?

1) I have the number 8883.
2) I would like to format the number so it shows up as 88.33.

Look at java.text.DecimalFormat. You can use it to transform
a double number to a string in just about any conceivable way.

BUT: It will not change the number as such, so you'd have to
produce the correct value first, possibly by dividing by 100
(taken that 8883 -> 8833 is a typo).

An alternative approach if your input is just a sequence of
*characters* (a String) rather than a number, you can produce
your desired output by string manipulation, i.e. insert a
decimal point at the correct spot in the string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top