Re: Working with exponents in code

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Peter N Roth (refusing.spam_at_mycompany.com)
Date: 03/02/05


Date: Wed, 2 Mar 2005 10:11:22 -0500

If you're using doubles throughout, then you'll

want to use Math.Pow( x, tothepower );

If you're using integers throughout, you might

want to consider multiple multiplies.

However, this is probably not going to be an

'inefficient' part of your program, so using Pow()

will most likely suffice. My guess is that VB uses

Pow() under the covers anyway.

-- 
Grace + Peace,
Peter N Roth
Engineering Objects International
http://engineeringobjects.com
Home of Matrix.NET
"Stefan L" <slueck@pp-software.REMOVEIfNoSpam.de> wrote in message 
news:%23XBZ5KzHFHA.3776@TK2MSFTNGP10.phx.gbl...
> Hi NG,
>
> I have the following problem:
>
> Is there a way to use exponents in C#-code without converting to a double 
> and then use System.Math?
>
> I have to convert VB-Code to C# and in VB its easy because you write:
> y = 5 ^ x
> meaning "Set y to 5 raised to the power of x"
>
> I didn't find a similar operator for C#, because "^" is a XOR-Operator.
> Am I blind or is there just no "easy" way to use exponents?
>
> TIA,
> Stefan 


Relevant Pages

  • float exponent
    ... anyone here know how to go about computing floating point exponents?... ... attempting to disassemble pow has not turned out well, as I think it goes off in some dll somewhere, and each place I look seems to jump somewhere else. ... all this is for my compiler, for which I have now added an exponent operator. ...
    (alt.lang.asm)
  • Re: inline power function replacement
    ... You're not writing a macro. ... Presumbly "pow" should be checking for integer exponents... ... Frederick Gotham ...
    (comp.lang.c)