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. .NET (Core and Framework)
  4. Single Precision not precise

Single Precision not precise

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphelpquestion
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.
  • A Offline
    A Offline
    AJGardiner
    wrote on last edited by
    #1

    I noticed some very stange values coming back from some calculations in a datatable and decided to investigate. Has anyone come across the problem below ?CSng(.51) + 0.01 0.51999999046325684 ?CSng(.57) + CSng(1) 1.56999993 I assume this is something to do with the way that the floating point value is held, but I've never seen it before. I'm using VB.NET to do this, but has anyone else noticed similar behaviour in other flavours of .NET? :confused:

    M P 2 Replies Last reply
    0
    • A AJGardiner

      I noticed some very stange values coming back from some calculations in a datatable and decided to investigate. Has anyone come across the problem below ?CSng(.51) + 0.01 0.51999999046325684 ?CSng(.57) + CSng(1) 1.56999993 I assume this is something to do with the way that the floating point value is held, but I've never seen it before. I'm using VB.NET to do this, but has anyone else noticed similar behaviour in other flavours of .NET? :confused:

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      What Every Computer Scientist Should Know About Floating Point Arithmetic[^]. Stability. What an interesting concept. -- Chris Maunder

      1 Reply Last reply
      0
      • A AJGardiner

        I noticed some very stange values coming back from some calculations in a datatable and decided to investigate. Has anyone come across the problem below ?CSng(.51) + 0.01 0.51999999046325684 ?CSng(.57) + CSng(1) 1.56999993 I assume this is something to do with the way that the floating point value is held, but I've never seen it before. I'm using VB.NET to do this, but has anyone else noticed similar behaviour in other flavours of .NET? :confused:

        P Offline
        P Offline
        Peter Ritchie
        wrote on last edited by
        #3

        Yes, anyone who has done any floating-point calculations on a computer has run into this. Welcome to floating-point. PeterRitchie.com

        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