Number Format
-
I am trying to display a number with two places to right of decimal. When the number diplays it truncates the trailling zero. I want to see .50 but I see .5 after I changed my datatype in the database to decimal from float. the number shows up like 2.25000009944 can someone tell me how do I display 1.50 with the zero in the database and the UI (web form). I tried looking for formatting in help but i can seem to get it right. Thanks
-
I am trying to display a number with two places to right of decimal. When the number diplays it truncates the trailling zero. I want to see .50 but I see .5 after I changed my datatype in the database to decimal from float. the number shows up like 2.25000009944 can someone tell me how do I display 1.50 with the zero in the database and the UI (web form). I tried looking for formatting in help but i can seem to get it right. Thanks
Hi, I think you should look around
string.Foramt()
methode which can have parameter like NumberFormatInfo MSDN Or, like this example, you can use theToString()
methode :string NumberPrettyPrint(int number){ // Gets a NumberFormatInfo associated with the en-US culture. NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat; nfi.NumberDecimalDigits = 2; return number.ToString("N", nfi); }
Hope that can help