Math.Pow gives “Cannot implicitly convert type 'double' to 'float' ” error

前端 未结 4 788
暖寄归人
暖寄归人 2021-01-21 12:23

In this program I am trying to create a simple calculator. However, I can\'t seem to find a way to overcome the aforementioned error when reaching the Math.Pow line

4条回答
  •  有刺的猬
    2021-01-21 13:26

    The return value of Math.Pow is a double. The variable power in your program is a float, which has a smaller range and accuracy.

    You should define power to be a double.

提交回复
热议问题