Math question?
Posted: Tue Apr 09, 2013 6:16 am
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
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