Because you are using float/double values, which are inherently not 100% precise (it's due to their binary representation). For example you can't even have precise 0.1
with floating-point numbers, because its binary representation is periodic 1.(1001)
. This is a very complete article on the matter: What Every Computer Scientist Should Know About Floating-Point Arithmetic
Tl;dr solution is to use decimal
for precise decimal arithmetic operations
var gh = Math.Abs(3.223m - 6.243m);