Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Number Format

Number Format

Scheduled Pinned Locked Moved C#
databasedesignhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mtone
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • M mtone

      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

      G Offline
      G Offline
      galinace
      wrote on last edited by
      #2

      Hi, I think you should look around string.Foramt() methode which can have parameter like NumberFormatInfo MSDN Or, like this example, you can use the ToString() 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups