Home   Help Search Login Register  

Author Topic: Rounding numbers downward  (Read 1205 times)

0 Members and 1 Guest are viewing this topic.

Bleumink

  • Guest
Rounding numbers downward
« on: 26 Aug 2002, 08:28:06 »
How do I round numbers downward?
For example, 1.2 is 1 and 1.9 also is 1.

DeusRich

  • Guest
Re:Rounding numbers downward
« Reply #1 on: 26 Aug 2002, 10:30:43 »
I can think of a way to do it, but that is huge, so do you have a range, like 1-10, or something like that, because it wont work with all numbers... there may be a command somewhere tho. Anyway, my idea is this:

in a script where the number in question has been passed to, it says:

Code: [Select]
_num = _this select 0

?(_num > 0 AND _num < 1):goto "check0"
?(_num > 1 AND _num < 2):goto "check1"
?(_num > 2 AND _num < 3):goto "check2"
?(_num > 3 AND _num < 4):goto "check3"
?(_num > 4 AND _num < 5):goto "check4"
?(_num > 5 AND _num < 6):goto "check5"
?(_num > 6 AND _num < 7):goto "check6"
?(_num > 7 AND _num < 8):goto "check7"
?(_num > 8 AND _num < 9):goto "check8"
?(_num > 9 AND _num < 10):goto "check9"
exit

#check0
_diff = _num - 0
_num = _num - _diff
exit


#check1
_diff = _num - 1
_num = _num - _diff
exit


#check2
_diff = _num - 2
_num = _num - _diff
exit


#check3
_diff = _num - 3
_num = _num - _diff
exit


#check4
_diff = _num - 4
_num = _num - _diff
exit


#check5
_diff = _num - 5
_num = _num - _diff
exit


#check6
_diff = _num - 6
_num = _num - _diff
exit


#check7
_diff = _num - 7
_num = _num - _diff
exit


#check8
_diff = _num - 8
_num = _num - _diff
exit


#check9
_diff = _num - 9
_num = _num - _diff
exit

neway, I think that'll work with anynumber between 0 and 10, to round them down, mayb you can do sumet to it so that itll automatically create 100, or 1000, mayb, but at the mo you cant really do rounding with one command, ie:_num = _num rounddown

ah well, hope this helps

Bleumink

  • Guest
Re:Rounding numbers downward
« Reply #2 on: 26 Aug 2002, 10:35:24 »
Thnx DeusRich, but i've figured it out.

_number = _number - (_number mod 1)