So I want to remove decimals from numbers and I’m wondering how my code on doing so could be improved. Here’s my current code for achieving this effect:

```
print(tonumber(tostring(math.random(1,5)):split'.'[1]))
```

So I want to remove decimals from numbers and I’m wondering how my code on doing so could be improved. Here’s my current code for achieving this effect:

```
print(tonumber(tostring(math.random(1,5)):split'.'[1]))
```

math.random will never output numbers with decimals just if you divide it after getting the number

but math.floor is the best way to get rid of decimals

1 Like