How do I round floats up? - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: How do I round floats up? (/thread-15621.html) |
How do I round floats up? - Cranky Old Man - 05-25-2012 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)? RE: How do I round floats up? - Your Computer - 05-25-2012 The code given in this post do what you have done and expect to do, so there may not be any other (simple) way. RE: How do I round floats up? - Cranky Old Man - 05-25-2012 (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! 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/docs/manual/doc_reserved_keywords.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. RE: How do I round floats up? - Apjjm - 05-25-2012 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. RE: How do I round floats up? - Cranky Old Man - 05-25-2012 (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. |