C# Int multiplied by float error in calculation...
This program multiplies an integer by a float (of a integer) to see if there is an error in the calculation. In C# there is an error with certain values. This occurs when mulitplying some integer values times another integer value that are only odd for each.
Such as: 3357(int) * 4999(float) = 16,781,644 instead of 16,781,643.
There are numerous other values that are produced. Interestingly there are only odd numbers for both that produce the calculation error.
$ dotnet build
$ dotnet run
On Linux there is quite a list of values that create discrepancies.
To perform the combination of multiplications on just two numbers provide the two numbers as arguments:
$ dotnet run 3055 6111
To perform the range calculation just put a Max Value as a single argument.
$ dotnet run 7000
This will calculate the combinations of multiplications for both numbers ranging from 1 to Max Value
To perform the Odd ball calculation execute without any parameters.
$ dotnet run
The Odd Ball calculation is a predetermined set of numbers that cause an error. These are set to compare to other platforms and languages such as C or Rust.
Odd ball calulations...
Notice that the 4th and 5th columns do not match.
The following shows the calculated values on Windows 10:
A very short list of the numbers with the error calculations is below:
A very short list of the numbers with the error calculations: