So, recently, i wrote a couple tweets where i explored how to theoretically overwrite the division implementation for C# numbers.
In short:
- C# doesn't really have "primitives" but .NET does.
- For primitives, division works with the
divinstruction. You can't edit this - C# does have first-class support like .NET's primitives (i.e. numeric literals, a keyword) for the
decimaltype decimalcorresponds toSystem.Decimalwhich is not a primitive type. Let'sbreak it!i mean, uhh, fix math!- The goal is to make
0 / 2 == 0.5, or since we're doing decimals only,0m / 2m == 0.5m. M for money i guess? i don't really know why that's the suffix C# uses,dwas already taken fordoublei guess.