Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I round floats up?
Author Message
Cranky Old Man Offline
Posting Freak

Posts: 925
Joined: Apr 2012
Reputation: 37
Post: #1
How do I round floats up?
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)?

Noob scripting tutorial: From Noob to Pro

05-25-2012 05:21 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,229
Joined: Jul 2011
Reputation: 215
Post: #2
RE: How do I round floats up?
The code given in this post do what you have done and expect to do, so there may not be any other (simple) way.

Tutorials: From Noob to Pro
05-25-2012 06:29 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Cranky Old Man Offline
Posting Freak

Posts: 925
Joined: Apr 2012
Reputation: 37
Post: #3
RE: How do I round floats up?
(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.

Noob scripting tutorial: From Noob to Pro

(This post was last modified: 05-25-2012 10:39 PM by Cranky Old Man.)
05-25-2012 07:12 PM
Find all posts by this user Quote this message in a reply
Apjjm Offline
Super Moderator

Posts: 444
Joined: Apr 2011
Reputation: 42
Post: #4
RE: How do I round floats up?
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.

(This post was last modified: 05-25-2012 07:30 PM by Apjjm.)
05-25-2012 07:29 PM
Find all posts by this user Quote this message in a reply
Cranky Old Man Offline
Posting Freak

Posts: 925
Joined: Apr 2012
Reputation: 37
Post: #5
RE: How do I round floats up?
(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

Noob scripting tutorial: From Noob to Pro

05-25-2012 07:43 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)