Author Topic: Floats  (Read 370 times)

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Floats
« on: May 19, 2012, 10:17:59 am »


               Why do I sometimes see floats set with an "f" after the value, for example:

float fRootBeer = 12.0f;

and other times the trailing "f" is omitted?

float fYourBoat = 10.0;

I have seen it both ways (in the same script, even) and can't find any rhyme or reason for the "f" at the end of the value in the first place, let alone why it is used for some but not other float values.
               
               

               


                     Modifié par Leurnid, 19 mai 2012 - 09:19 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Floats
« Reply #1 on: May 19, 2012, 12:11:35 pm »


               Because some noobs, like myself, didn't realize that you don't have to put the f after the actual float..

'<img'>
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Floats
« Reply #2 on: May 19, 2012, 01:30:17 pm »


               It is a legacy format of older programming languages.  The option of having the f at the end of the float was left for the convenience of people who where either use to it or liked having it.  That way they would not have to change there syntax from one language to another.  In NWNscript it is simply optional, in other languages it is mandatory.
               
               

               
            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Floats
« Reply #3 on: May 19, 2012, 06:53:15 pm »


               Thank you.