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. Single/Double.ToString() help

Single/Double.ToString() help

Scheduled Pinned Locked Moved C#
tutorialquestionhelp
3 Posts 3 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.
  • V Offline
    V Offline
    Verdant123
    wrote on last edited by
    #1

    i cannot for the life of me figure out how to get this to return a string that is not formatted in scientific notation is there a simple guide or set of examples somewhere on how to use IFormatProvider? msdn doesn't seem to provide any examples edit: i found an example, it uses a mask... but why does the msdn page mention special characters (d/c/etc) for formating? where can i find a reference for the available masks?

    W H 2 Replies Last reply
    0
    • V Verdant123

      i cannot for the life of me figure out how to get this to return a string that is not formatted in scientific notation is there a simple guide or set of examples somewhere on how to use IFormatProvider? msdn doesn't seem to provide any examples edit: i found an example, it uses a mask... but why does the msdn page mention special characters (d/c/etc) for formating? where can i find a reference for the available masks?

      W Offline
      W Offline
      Werdna
      wrote on last edited by
      #2

      This is a link to really good site on how to format numbers: http://authors.aspalliance.com/aspxtreme/aspnet/types/numericformatstrings.aspx

      1 Reply Last reply
      0
      • V Verdant123

        i cannot for the life of me figure out how to get this to return a string that is not formatted in scientific notation is there a simple guide or set of examples somewhere on how to use IFormatProvider? msdn doesn't seem to provide any examples edit: i found an example, it uses a mask... but why does the msdn page mention special characters (d/c/etc) for formating? where can i find a reference for the available masks?

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        You keep reading the wrong things. Did you try reading the documentation for the NumberFormatInfo, which implements IFormatProvider? You don't even need to specify this for numeric types in string.Format (or any other formatting method like Console.WriteLine). There's also a big section on formatting in the .NET Framework SDK, which should be your first stop for .NET-related documentation, articles, and examples. There is a simple solution for the scientific notation:

        string s = string.Format("{0:e}", myNum);
        // OR
        s = myNum.ToString("e"); // Also documented in numeric type's ToString docs

        Microsoft MVP, Visual C# My Articles

        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