I'm not that great with maths and C# doesn't seem to provide a power-of function so I was wondering if anyone knows how I would run a calculation like this:
var dimensions = ((100*100) / (100.00^3.00));
Another solution is to keep dividing the number by two, i.e, do n = n/2 iteratively. In any iteration, if n%2 becomes non-zero and n is not 1 then n is not a power of 2. If n becomes 1 then it is a power of 2.
In other words, a pow() function is used to calculate the power of the base number (x) by raising the power of (y) as (xy). For example, we take base as 2 and power as 5, the power of a number using the pow(2, 5) function to return a value as the 32.
See Math.Pow. The function takes a value and raises it to a specified power:
Math.Pow(100.00, 3.00); // 100.00 ^ 3.00
You are looking for the static method Math.Pow()
.
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