Search Unity

How to define anything

Discussion in 'Scripting' started by Jonhas, Aug 16, 2019.

  1. Jonhas

    Jonhas

    Joined:
    Jul 28, 2019
    Posts:
    46
    It is simple, how to define anything, by that I mean any, like if a Player's position was X 60 and Y Z anything, I would like it in the form of a float, basically anything, simple.
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    Well float only has values for:
    real number (a value that fits with in the range of float)
    0 or -0 (yes float technically has a negative 0)
    inf or -inf
    NaN (both signaling and quiet represented by its sign)

    You don't really have any other float values to choose from.

    If you want to just 'say' that 'NaN' is "anything"... you can go right ahead and treat NaN as anything. Though this means any operations you perform on floats that result in NaN will put the float into your defined "anything" state.

    Though mind you NaN equality is NOT equal by definition. You have to use float.IsNaN to test for NaN.
     
  3. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    "Anything" is not a value, it is a condition. Like "less than four".

    You can ask "is the value of this variable less than four?" but you can't say "set the value of this variable to less than four". You have to set it to an actual specific value.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  5. Jonhas

    Jonhas

    Joined:
    Jul 28, 2019
    Posts:
    46
    Thanks for letting me know both of you!