Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

What does the 'f' stand for in Mathf?

Discussion in 'Scripting' started by User340, Jul 13, 2014.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Hi,

    You see it everywhere, Mathf.Clamp01, Mathf.Lerp, Mathf.PI, yet remains such a mystery as to why there is an f at the end. Why not just Math.Clamp and what does the 'f' stand for??
     
  2. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,548
    Probably function...
     
    Last edited: Jul 13, 2014
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    float

    Standard .NET Math class uses double. Unity made a wrapping class that cast float into double and back into float for your convenience.
     
    FVS likes this.
  4. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    So, function or float?

    @LightStriker: So are you saying the Mathf is in essence nothing but a wrapper class (around System.Math)?
     
  5. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    It's float. And yes, Mathf is a wrapper class that does all the casting for you.
     
  6. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    If you decompile it, yes, it is just that.
     
  7. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Okay, thanks. Would it have been so hard to add one line in the docs that says: "f stands for float"??
     
  8. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    617
    fat ass class is what it stands for

    could use some trimming
     
    emredesu likes this.
  9. zDemonhunter99

    zDemonhunter99

    Joined:
    Apr 23, 2014
    Posts:
    478
    Sometimes you have to find the answers to questions yourself, young Padawan. :p
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity is based on float. Only C# isn't by default. Not many people are bothered by the f :p
     
  11. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    617
    Your Euro-self should be upset its not called Mathsf.
     
  12. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Hahaha, I would if it was SOMEWHERE online. But for some reason the whole internet didn't have the answer to my question. :)
     
  13. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    617