First of all, your code doesn't even compile.
If you want to use 12.123
as a decimal
, you need to use m
or M
suffix. If you don't use any suffix with your floating type, C# thinks it is a double
.
From decimal
(C# Reference)
If you want a numeric real literal to be treated as decimal, use the
suffix m or M. Without the suffix m, the number is treated as a double
and generates a compiler error.
And there are no implicit conversions between floating-point types (float
and double
) and the decimal
type.
Since Math.PI
field represents double
, your Math.PI / 180
will be double
. Since mLat
is decimal
(you said it is a spelling mistake) you try to get double * decimal
which is clearly you get these error. You try to same operation with /
operator also.
From C# Spec $7.7.1 Multiplication operator
float operator *(float x, float y);
double operator *(double x, double y);
decimal operator *(decimal x, decimal y);
And from C# Spec $7.7.2 Division operator
float operator /(float x, float y);
double operator /(double x, double y);
decimal operator /(decimal x, decimal y);
As you can see from these documentations, there is no defined double * decimal
or double / decimal
operations.