So I\'m trying to figure out why the modulo operator is returning such a large unusual value.
If I have the code:
double result = 1.0d % 0.1d;
The error you see is small; it only looks large at first glance.
Your result (after rounding for display) was
0.09999999999999995 == (0.1 - 5e-17) when you expected 0 from a
% 0.1 operation.
But remember that this is almost 0.1, and 0.1 % 0.1 == 0.
So your actual error here is -5e-17. I would call this small.
Depending on what you need the number for, it might be better to write:
double result = 1.0 % 0.1;
result = result >= 0.1/2 ? result - 0.1 : result;