# Tick is supper glitched!

Why is this happening? Is anyone else having this issue?

``````local TICK = tick()
print(tick() - TICK)
``````

9.5367431640625e-07 --> Output

That’s weird, but I just tried it and it printed 0 for me.

Edit: Did it a second time and I got a weird number like you, but then I ran it again and it was 0.

2 Likes

Should I report this as a bug? The thing is, is going to take supper long to be approved so idk.

I got the same thing as you, sometimes it’s 0, and sometimes its that crazy number. It’s literally the exact number.

1 Like

It’s probably just a rounding error with floating point precision. 9 * 10^-7 is a really small number anyway.

If your code relies on it being exactly zero you can probably round it to the nearest thousandth or something.

2 Likes

When working with tick it is good to use math.floor, since it will remove any additional decimal places.

``````local TICK = tick()
print(math.floor(tick() - TICK)) -- this should print 0
``````
1 Like

I just printed it out in a different way, and now I get a .00008, so like Blokav said, most likely a rounding issue. This is the way I did it.

``````TICK = tick()
cool = tick() - TICK
print(cool)
``````
1 Like

Yeah but, I used to get normal numbers before. Idk what’s happening.

It is not a bug, tick() is just very precise, as I said use math.floor or round it to how many decimal places you need. (even though it is unnecessary)

1 Like

Each line of code has to be run sequentially. So what is actually happening is that you are measuring the microscopic amount of time between the line where you set the variable and the time where you perform the subtraction operation. The `print` function also takes time to run.

But like @cjjdawg said if you’re counting time in terms of single seconds or hundredths of seconds the difference is negligible.

3 Likes

If you want it to get a round number, you can use `math.floor()`
For example:

`local t = tick()`
`print(math.floor(tonumber(t)) - math.floor(tonumber(tick)))`

Output: 0