How to calculate a power of function

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
C

cmdolcet69

How do youdisplay the power of a number in vb.net? I thought the ^
would work however it will not.

Public _sngOperand As Single
stackoperand.Push(New Operand(op2._sngOperand ^ op1._sngOperand))
 
Does the power fucntion need to be of double type? and can;t be single
type

Public Shared Function Pow(x As Double, y As Double) As Double

.. means it only accepts double data type.


Thanks,

Onur Güzel
 
cmdolcet69 said:
Ok i get an error saying that the Overload resolution failed because
no accesible 'New : can be called without narrowing conversion.
Public sub New(sngnum as single) argument matching parameter sngnum
narrows from double to single.

The result is a Double, so if you need it to be a Single, you have to
cast it. (As the cast reduces the precision, it's not done automatically.)
 
Back
Top