wazup07
|
  |
| Joined: 17 Oct 2009 |
| Total Posts: 313 |
|
|
| 04 Aug 2013 06:44 PM |
local f = I.Value*(1+.01)^Time
What I have here is an equation that results in an exponential growth. My problem though, is that this will output numbers with long strings of decimals. Is there any way to round the output, f, to the nearest whole number and then use that elsewhere? Thanks.
|
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
| |
|
|
| 04 Aug 2013 06:47 PM |
there is probably a better way but here is how u could do it
local round = 1000 num = math.floor(num *round+.5)/round
change round by multiplying ten or dividing ten to change amt decimal points |
|
|
| Report Abuse |
|
|
wazup07
|
  |
| Joined: 17 Oct 2009 |
| Total Posts: 313 |
|
|
| 04 Aug 2013 06:59 PM |
| Great thanks! adark's version worked out just fine, but i'll keep your method in mind. |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2013 07:36 PM |
| Yeah his method is a lot better but you can keep some decimal places with mine if you choose to |
|
|
| Report Abuse |
|
|
wazup07
|
  |
| Joined: 17 Oct 2009 |
| Total Posts: 313 |
|
|
| 04 Aug 2013 09:14 PM |
Another question, is it posible to detect if a number is a whole number? For instance, if I were to add say 0.1 to 1 during a repeated loop, is there a way to detect when that number reaches a whole number? I don't mean like
if Number == 2 then
because I won't always have that exact value. Is something like this possible? |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 05 Aug 2013 11:11 AM |
if Number == math.floor(Number + .5) then
Of course, this will most likely never run because floating point imprecision. |
|
|
| Report Abuse |
|
|