Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How to check for nan

    Help
    2
    3
    183
    Loading More Posts
    • 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.
    • PB____
      PB____ last edited by

      Is there a way to check if a value is not a number nan? I could prevent using negative values with sqrt, so no problem if it's not possible, but I noticed that even sqrt(-1) == sqrt(-1) equals false...

      I do agree with the choice to tolerate weird input values like this, since it aligns well with the use-case for Fuze. It's just a little unexpected quirk i happened to run into.

      1 Reply Last reply Reply Quote 0
      • spikey
        spikey F last edited by

        silly idea, what about: (partially tested)

        n = sqrt(-1)
        if (str(n) == "nan") then
           print("is no valid number")
        endif
        
        1 Reply Last reply Reply Quote 2
        • PB____
          PB____ last edited by

          Nice, that works 👍

          1 Reply Last reply Reply Quote 0
          • First post
            Last post