int n = 5;
int quorum = Math.Floor(n / 2) + 1;
I'm expecting quorum to have value 3. But this is the error I get in VisualStudio:
The call is ambiguous between the following methods or properties: 'System.Math.Floor(double)' and 'System.Math.Floor(decimal)'
How do I correct it? Where did I go wrong?
The call is ambiguous between the following methods or properties: 'Assert. That(ActualValueDelegate, IResolveConstraint)' and 'Asser - Visual Studio Feedback.
You have no need to use Math.Floor
. Because all of your terms are integers, .NET will perform integer division which automatically truncates the remainder of the output anyway.
As for why you're getting the error, as stated above the result of integer division is still an integer. Because you can't floor an integer (there's no fractional component to round down), there's no overload of Floor
that takes an int
. The call would have to convert the result to a decimal
or double
first, and the compiler doesn't know which one you want (which is, in fact, neither).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With