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 / C++ / MFC
  4. Why -nan values appear

Why -nan values appear

Scheduled Pinned Locked Moved C / C++ / MFC
c++
6 Posts 6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values

    J K D CPalliniC 4 Replies Last reply
    0
    • L Lost User

      I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Because the math operations performed by your code result in a NaN? You cast an integer with at least the relevant most signficant bits set to float or double? You have a buffer overflow writing such a value to the memory of a float or double? Without seeing code, we can't tell you for sure.

      1 Reply Last reply
      0
      • L Lost User

        I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values

        K Offline
        K Offline
        k5054
        wrote on last edited by
        #3

        2 most likely reasons: Invalid math e.g. division by zero, or use of uninitialized variables. Without seeing your code, and input, we can't know.

        P 1 Reply Last reply
        0
        • L Lost User

          I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Because what ever you are doing, the result is not a number.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          1 Reply Last reply
          0
          • L Lost User

            I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            Have a look at IEEE 754-1985 - Wikipedia[^].

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • K k5054

              2 most likely reasons: Invalid math e.g. division by zero, or use of uninitialized variables. Without seeing your code, and input, we can't know.

              P Offline
              P Offline
              Peter_in_2780
              wrote on last edited by
              #6

              ahem... Division by zero in general produces a (signed) Inf, not a NaN.

              Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

              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