Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Formatting a number, placing the decimal in the proper place

Reply
Thread Tools

Formatting a number, placing the decimal in the proper place

 
 
BoomerangThree
Guest
Posts: n/a
 
      08-20-2004
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...

--
BoomerangThree


 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      08-20-2004
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..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
 
 
 
BoomerangThree
Guest
Posts: n/a
 
      08-20-2004
Understand. Won't happen again.


"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:lm97wks2b3qn$(E-Mail Removed)...
> 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..
>
> --
> Andrew Thompson
> http://www.PhySci.org/ Open-source software suite
> http://www.PhySci.org/codes/ Web & IT Help
> http://www.1point1C.org/ Science & Technology



 
Reply With Quote
 
Jacob
Guest
Posts: n/a
 
      08-20-2004
BoomerangThree wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
decimal.Decimal formatting python@lists.fastmail.net Python 0 07-19-2010 12:32 PM
Error: Cannot convert Decimal("0.0000") to Decimal Vitaliy Python 1 05-29-2008 10:36 AM
TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why? Gilbert Fine Python 8 08-01-2007 01:58 AM
Decimal to Packed Decimal Conversion in C++ Ven C++ 3 08-01-2006 03:56 PM
Newbie: Placing DOCTYPE tag on HTML file screws up formatting KS HTML 7 11-10-2004 08:46 AM



Advertisments