OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ModestNovice on 21 Dec 2008, 18:24:42

Title: Way to get whole numbers only?
Post by: ModestNovice on 21 Dec 2008, 18:24:42
Hello, Im wondering if there is a way to get a whole number only. As Im using floor and distance. Which works, but the person has to pay it. And it is creating some bad numbers to pay.

Say the distance:
Code: [Select]
_total = (floor(DCV_TaxiStartPos distance DCV_TaxiEndPos)/1000)*100;though this can return 4.3 or 4.7 and so on.

is there a way to round to the nearest whole number?

Thanks,
DaChevs


*EDIT* WOoooowwww.... -> command round

(SOLVED)
Title: Re: Way to get whole numbers only?
Post by: Spooner on 21 Dec 2008, 18:49:39
There are floor (round down) ceil (round up) and round (round to nearest). Since you are using a monetary system, you might prefer ceil, since then no journey will be free :P Also, when rounding in any way with maths, it is usual to round at the end, not at any earlier point:
Code: [Select]
_total = ceil (((DCV_TaxiStartPos distance DCV_TaxiEndPos) / 1000) * 100);
Title: Re: Way to get whole numbers only?
Post by: ModestNovice on 21 Dec 2008, 20:43:29
righto, thanks Spooner  :good: :clap: