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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to convert a string to double with out lossing precission??

How to convert a string to double with out lossing precission??

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 Posts 3 Posters 4 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.
  • P Offline
    P Offline
    prathapcode
    wrote on last edited by
    #1

    Hi, I have a string with value "111733394601234567094987654321" . Now i want to divide this with 636. I convert it to double , then im getting 1.1173339460123456E+29 . but these both values are differnt finally im getting wrong output. can anyone help me..... Thanks Prathap

    M L 2 Replies Last reply
    0
    • P prathapcode

      Hi, I have a string with value "111733394601234567094987654321" . Now i want to divide this with 636. I convert it to double , then im getting 1.1173339460123456E+29 . but these both values are differnt finally im getting wrong output. can anyone help me..... Thanks Prathap

      M Offline
      M Offline
      Moreno Airoldi
      wrote on last edited by
      #2

      There is no way you can do that with doubles. Since the value is too big even for a 64 bit integer, you should use some 128-bit integer class. See for example this[^] or Google for some more.

      2+2=5 for very large amounts of 2 (always loved that one hehe!)

      1 Reply Last reply
      0
      • P prathapcode

        Hi, I have a string with value "111733394601234567094987654321" . Now i want to divide this with 636. I convert it to double , then im getting 1.1173339460123456E+29 . but these both values are differnt finally im getting wrong output. can anyone help me..... Thanks Prathap

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        The latest .NET 4.0 (and Visual Studio 2010) is in beta and offers a BitInteger class which would easily take care of your big integer division, yielding accurate quotient and remainder values. There also have been some articles on home-brew BigInteger classes here on CP (with varying functionality and quality). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        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