Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: How to format a float number?

Reply
Thread Tools

Re: How to format a float number?

 
 
Jon A. Cruz
Guest
Posts: n/a
 
      08-20-2003
Michiel Konstapel wrote:
>>How to format a float number to 2 digits after the decimal point?

>
>
> See java.text.NumberFormat and DecimalFormat.



Often it's better to use java.text.MessageFormat.


String format = LoadMyResource( key );

// Gets a string like
// "The scale is {0,number,#.##} on {1,number,integer}"
// or
// "Ethay alescay onway {1,number,integer} isway {0,number,#.##}"


String result = MessageFormat.format( format, new Object[] {scale,
passInt} );

 
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
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
operator== (float, float) Jukka Lehtonen C++ 5 08-05-2004 08:28 AM
need code to convert float format to internal java float format which is kept in 4 bytes integer Andy Java 7 05-10-2004 09:26 PM
static_cast<float>(a) versus float(a) Jim West C++ 4 01-16-2004 12:36 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments