Can I round up numbers to turn a double into an int?


After calculation, HP sometimes end up with decimals. How do I round them up or down?

You use the functions Ceiling() (rounds up), Floor() (rounds down), or Round() (rounds to the closest int).

Quest offers four functions that will round your double to an integer. Note, however, that the type will still be double. Rounding a double with the value 4.56 will give a double with the value 4.00.

Ceiling - (Round up)
Floor - (Round down)
To display a double to, say, three decimal places, multiple it by 1000, then round it, then divide by 1000.

msg("The objective is " + (Round(distance * 1000)/1000) + " km away.")
To convert to an integer type you will need to use cast (note that there are no quotes around int).

my_int = cast(4.56, int)

mx player for pc ok here

This topic is now closed. Topics are closed after 60 days of inactivity.