Turning a decimal number into an integer

Quick question guys, how do you convert a number with decimal points to an integer, for example:

197.01015202268 to 197.

The only way’s I can figure out to do it is:

Use % (modulo) to give me a remainder of the value and then take the value from the original number, or,

Convert the value to a string, look for the . (fullstop), take out the numbers before it and then convert back to number value. Which is a bit of a long way round.

I’ve had a look through the math.functions in the API but none seem to be relevant as I’m not passing any arguments and I don’t want to round off the decimals, I just need the integer.

Is there a simple and easy solution to this, or is it just that I can’t see the wood for the tree’s?

Also code would be nice, (if its needed) :slight_smile:

I haven’t checked this, but perhaps math.floor for positive number?  And math.ceil for negative number?

Naomi

Thankyou Naomi, it works perfectly.

The first time I read the API for math.floor it sounded like it returned a value in relation to another number, not the number I was using. Thank-you for clearing that up for me.

Ah, glad to hear it works with what you’re trying to do.

Cheers,

Naomi

I haven’t checked this, but perhaps math.floor for positive number?  And math.ceil for negative number?

Naomi

Thankyou Naomi, it works perfectly.

The first time I read the API for math.floor it sounded like it returned a value in relation to another number, not the number I was using. Thank-you for clearing that up for me.

Ah, glad to hear it works with what you’re trying to do.

Cheers,

Naomi