Re: Controlling number of decimal places
From: Lars-Inge Tønnessen [VJ# MVP] (http://emailme.larsinge.com)
Date: 02/25/05
- Previous message: Lars-Inge Tønnessen [VJ# MVP]: "Re: J# java.util.Calendar bug????????"
- In reply to: Lou: "Controlling number of decimal places"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 25 Feb 2005 21:48:46 +0100
Please use System.String.Format( "{0:#.00}", System.Convert.ToDecimal(
value ) ) to format the number of digits.
{0 = the parameter index. We only have 1 parameter so this will always be 0.
# = the value, it does not matter how many digits.
0 = represents a digit.
Example:
//double value = 1.2344567;
double value = 111.2;
String s_value = System.String.Format( "{0:#.00}",
System.Convert.ToDecimal( value ) );
System.Console.WriteLine( "The value is: " + s_value );
output:
The value is: 111.20
Eg
String s_value = System.String.Format( "{0:#.000}",
System.Convert.ToDecimal( value ) );
Will give:
The value is: 111.200
Regards,
Lars-Inge Tønnessen
- Previous message: Lars-Inge Tønnessen [VJ# MVP]: "Re: J# java.util.Calendar bug????????"
- In reply to: Lou: "Controlling number of decimal places"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|