Jump to content
  • 0

How to convert a float to an int?


RobotMonkeyHead

Question

Ok, I realize this is a pretty basic question.
For example if I run the following code, it produces a debug flood, saying truncated float to int.

alpha = 256 - (256 / (time * .25)), 256

Is there an easy way to just round that noise inside the parenthesis to an int?

      onp7EZ9.png

~ℛ.ℳ.ℋ. 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

floor() or ceil(). Unfortunately, there is no "round" or I'd easily suggest that. floor() will drop all digits past the decimal point and ceil() will round up and return the least possible Int.

Think of floor() as rounding down and ceil() as rounding up. I think that's the easiest way to explain it.

 

51fd7dd1e8049.png

-[Все слова это только слова.]-

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...