Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does the 'f' do in a script when behind a float?
Mina Darsh Offline
Member

Posts: 227
Threads: 24
Joined: Sep 2010
Reputation: 0
#1
What does the 'f' do in a script when behind a float?

Well, as the topic title asks: What does the 'f' do in a script when behind a float? Seeing it a lot, but I was unable to find out what it does so far. Huh
04-15-2011, 05:41 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: What does the 'f' do in a script when behind a float?

It's just used to state the number is a float. So if you have a float number parameter, if it's not an integer, you'll have to put an f in the back. Ex: 3.1f, 4.5f, etc.

At least I'm pretty sure that's it. Doesn't make sense either since the float is already called...
04-15-2011, 06:16 PM
Find
Mina Darsh Offline
Member

Posts: 227
Threads: 24
Joined: Sep 2010
Reputation: 0
#3
RE: What does the 'f' do in a script when behind a float?

So the 'f' is not necessary, I assume?
04-15-2011, 06:50 PM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#4
RE: What does the 'f' do in a script when behind a float?

It is not necessary, but it tells the compiler to allocate just enough space for the float.

04-15-2011, 07:53 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#5
RE: What does the 'f' do in a script when behind a float?

I don't get why they bother with the int and float declarations then. :V

Actually that's a good question in general, why do high level programming languages do that? Why wouldn't there simply be a single data type for all numbers, and the ability to detect their precision to allocate the appropriate memory?
04-15-2011, 11:00 PM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#6
RE: What does the 'f' do in a script when behind a float?

Because you need different things for different applications?

Making each data type the size of a long is stupid when you only need a number that goes up to 100 for example.

Also, if the compiler were to detect, it would slow the compiling process down, alot. And it will generally make your programs inefficient because a compiler may make mistakes.

04-15-2011, 11:05 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#7
RE: What does the 'f' do in a script when behind a float?

No I mean, like with the f in this script, why not determine the data per value instead of per variable? Wouldn't it be more efficient with coding, as well as with the program since you could tell each value exactly what size it should be?
04-15-2011, 11:16 PM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#8
RE: What does the 'f' do in a script when behind a float?

... You only use f when you punch in a literal value... you don't do that to variables.

04-16-2011, 12:25 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#9
RE: What does the 'f' do in a script when behind a float?

Sorry, I meant constant values, not variables. And I didn't realize until I looked it up that you can do that in C++ and otherwise. Sorry, just a little confusion there. xD
04-16-2011, 12:28 AM
Find
Tottel Offline
Senior Member

Posts: 307
Threads: 9
Joined: Nov 2010
Reputation: 0
#10
RE: What does the 'f' do in a script when behind a float?

You don't use constant values thát often in programming. Smile
04-16-2011, 10:44 AM
Find




Users browsing this thread: 1 Guest(s)