What is the command to get only the interger part of a number?
I tried e = math.abs(a*.3) but that gives a decimal point.
I tried e = math.int(a*.3) but that gives an error "attempt to call field a nil value"
ow can I get just the whole number of 30% of a and assign it to e.
Thanks.
----------edit ----------
Found it.
math.modf
Looking at the description it returns both the interger and the remainder so what I am doing is
e = math.modf(a*.3)
print e
> 27
If I wanted to use both (I don't in this case but for learning purposes, would it go like this?
e,f = math.modf(a*3)
print e,f
>27 .5
Math question?
Re: Math question?
Also, just to get the integer part: math.floor (and math.ceiling to 'round' up).Ryeath_Greystalk wrote:What is the command to get only the interger part of a number?
I tried e = math.abs(a*.3) but that gives a decimal point.
I tried e = math.int(a*.3) but that gives an error "attempt to call field a nil value"
ow can I get just the whole number of 30% of a and assign it to e.
Thanks.
----------edit ----------
Found it.
math.modf
Looking at the description it returns both the interger and the remainder so what I am doing is
e = math.modf(a*.3)
print e
> 27
If I wanted to use both (I don't in this case but for learning purposes, would it go like this?
e,f = math.modf(a*3)
print e,f
>27 .5
alois
-
Ryeath_Greystalk
- Posts: 366
- Joined: Tue Jan 15, 2013 3:26 am
- Location: Oregon
Re: Math question?
Thanks for that additional information alois.
I saw the math.floor and math.ceil and for some reason thought they returned the upper and lower end of a range. Don't know where I came up with that crazy idea.
I saw the math.floor and math.ceil and for some reason thought they returned the upper and lower end of a range. Don't know where I came up with that crazy idea.