why do i get a "Nan" as an out put when trying to calculate something?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gibran
    New Member
    • Sep 2010
    • 2

    why do i get a "Nan" as an out put when trying to calculate something?

    I assigned the variable 'grosspay' as a float, when calculating it which is adding up the 'regularpay' plus 'overtimepay' (both of these variables were assinged as floats too)
    I get 'Nan'

    any help would be greatly appreciated
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    The calculation you have done has resulted in an error in the floating point processor.

    NaN mean Not a Number

    The floating processor has put in some trap value (a combination of bits in the variable that does/can not represent an actual value) that the library recognises and it outputs NaN because there is no numerical representation.

    Check your maths, then check the way you have implement the maths in the code.

    Comment

    • gibran
      New Member
      • Sep 2010
      • 2

      #3
      Thank you!

      i found my mistake.

      Comment

      Working...