Custom magnitude function inaccuracy?

I was recently playing around with vectors and I decided to make my own custom magnitude function as shown below:

local function magnitude(vector)
    return math.sqrt(vector.x^2 + vector.y^2 + vector.z^2)

It works just fine, however, when comparing it to the normal .Magnitude method there seems to be a very small difference.

My question is simple: why? Is it an inaccuracy with math.sqrt?
I am merely curious, as I have no use for my own magnitude function.

Accord to the output, your function is actually more accurate. Note the extra decimal precision.
There’s such negligible difference that it’s practically ==. I wouldn’t sweat over it too much.

Oh lol, awesome
It doesn’t really matter to me anyway, I was just curious as to why there was a small difference.


Here’s the results of a unit test:
Sample size : 2^20


Double floating point precision errors, in other words there aren’t enough available bits to accurately represent your number.