Home   Help Search Login Register  

Author Topic: Way to get whole numbers only?  (Read 1250 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
Way to get whole numbers only?
« 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)
« Last Edit: 21 Dec 2008, 18:31:02 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Way to get whole numbers only?
« Reply #1 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);
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Way to get whole numbers only?
« Reply #2 on: 21 Dec 2008, 20:43:29 »
righto, thanks Spooner  :good: :clap:
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley