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
How do I round floats up?
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#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
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#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
Website Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#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
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#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
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#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




Users browsing this thread: 1 Guest(s)