Frictional Games Forum (read-only)

Full Version: How do I round floats up?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
AngelScript seems to need a math addon to do ceil() and floor(), so all I can do is to bash the float into an int.

More specifically, I find it impossible to have GetPlayerSanity() return values such as "90" or "50". Instead I get "89" and "49". Can I do anything about this (without simply adding 1 to the value)?
The code given in this post do what you have done and expect to do, so there may not be any other (simple) way.
(05-25-2012, 06:29 PM)Your Computer Wrote: [ -> ]The code given in this post do what you have done and expect to do, so there may not be any other (simple) way.
Thank you! Smile
However, Geany suggests roundf() (and round() and roundl() ), as these are valid C functions (as listed in the c99.tags file). If I were to make an angelscript.tags file instead, where would I find a good reference of all the valid tags?

Edit:
Nevermind. I think I found a list here:
http://www.angelcode.com/angelscript/sdk...words.html

Edit 2:
Actually, the c99.tags file only contains C functions, not keywords, so simply removing c99.tags from the folder, will get rid of that annoyance.
For future reference, you can always do ceil(X)=floor(x)+1 [if x != floor(x)]. Where floor(x) is simply casting to an integer.
(05-25-2012, 07:29 PM)Apjjm Wrote: [ -> ]For future reference, you can always do ceil(X)=floor(x)+1 [if x != floor(x)]. Where floor(x) is simply casting to an integer.
Yeah, that's what you wrote in the code that YourComputer linked to. Smile