我相信这并不像我所想象的那么困难。
想使用与Math.Pow(double,double)等效但输出整数的内容。我担心浮点舍入误差。
我能想到的最好的方法是:
我想到了这个:
但是我收到错误信息,操作符 "<<" 不能用于 int或 和 uint 类型的操作数。
有什么建议吗?感谢您一如既往的帮助。
想使用与Math.Pow(double,double)等效但输出整数的内容。我担心浮点舍入误差。
我能想到的最好的方法是:
uint myPower = 12;
uint myPowerOfTwo = (uint)Math.Pow(2.0, (double)myPower);
我想到了这个:
我有一个想法:
uint myPowerOfTwo = 1 << myPower; // doesn't work
但是我收到错误信息,操作符 "<<" 不能用于 int
有什么建议吗?感谢您一如既往的帮助。