So I have a script that does stuff with numbers.

And the number can become like:

3.358977707997

I want it to only display lets say:

3.3

Which would be the first decimal of the number. Anyway to do this?

So I have a script that does stuff with numbers.

And the number can become like:

3.358977707997

I want it to only display lets say:

3.3

Which would be the first decimal of the number. Anyway to do this?

i haven’t tested this fully, but:

```
function SingleDecimal(n)
return math.floor(n * 10) / 10
end
local Result = SingleDecimal(3.358977707997)
print(Result)
```

2 Likes

Thanks!

This worked first try ngl!

I’d recommend subtracting the remainder of number/0.1 from the number. Remainder can be found with the modulus, so `number = number - (number%0.1)`

. Alternatively, if you want to round the number instead of just chopping off the last decimal, you can use this round function I made:

```
local function round(num, near)
return (num + near/2) - ((num + near/2) % near)
end
```

Edit: solved right as I replied.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.