如何解决这个bug? [英] How to solve this bug?

查看:86
本文介绍了如何解决这个bug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





有谁知道如何在2013年的vb.net中解决以下问题?

Hi,

Does anyone know how to solve the following in vb.net 2013 ?

Dim x1 As Double = -0.3
Dim x2 As Double = 0.7
Dim xx As Double = x1 ^ x2 '=-1.#IND
xx = Math.Pow(x1, x2)      '=-1.#IND
xx = -0.3 ^ 0.7            '= -0.43051162024993422
xx = Math.Pow(-0.3, 0.7)   '=-1.#IND



谢谢


Thanks

推荐答案

如果你看一下Math.Pow [ ^ ]它说:

If you look at the definition of Math.Pow[^] it says:
x < 0 but not NegativeInfinity; y is not an integer, NegativeInfinity, or PositiveInfinity.
Returns NaN



请尝试:


So try:

xx = Math.Sign(x1) * Math.Pow(Math.Abs(x1), x2)


没有错误。 ^ 运算符不用于执行指数运算。该运营商是独家运营商。请参阅文档:

^运算符 [ ^ ]
There is no bug. The ^ operator is not for performing exponent operations. This operator is an exclusive-or operator. Please see the documentation:
^ Operator[^]


这篇关于如何解决这个bug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆