Frictional Games Forum (read-only)
What does the 'f' do in a script when behind a float? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: What does the 'f' do in a script when behind a float? (/thread-7390.html)



What does the 'f' do in a script when behind a float? - Mina Darsh - 04-15-2011

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


RE: What does the 'f' do in a script when behind a float? - MrBigzy - 04-15-2011

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...


RE: What does the 'f' do in a script when behind a float? - Mina Darsh - 04-15-2011

So the 'f' is not necessary, I assume?


RE: What does the 'f' do in a script when behind a float? - xiphirx - 04-15-2011

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


RE: What does the 'f' do in a script when behind a float? - MrBigzy - 04-15-2011

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?


RE: What does the 'f' do in a script when behind a float? - xiphirx - 04-15-2011

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.


RE: What does the 'f' do in a script when behind a float? - MrBigzy - 04-15-2011

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?


RE: What does the 'f' do in a script when behind a float? - xiphirx - 04-16-2011

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


RE: What does the 'f' do in a script when behind a float? - MrBigzy - 04-16-2011

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


RE: What does the 'f' do in a script when behind a float? - Tottel - 04-16-2011

You don't use constant values thát often in programming. Smile