Re: Working with exponents in code
From: Peter N Roth (refusing.spam_at_mycompany.com)
Date: 03/02/05
- Next message: Michael Voss: "Re: Trying to print batch of PDF files programmatically"
- Previous message: Carlos J. Quintero [.NET MVP]: "Re: Newbie Question: Commented Code"
- In reply to: Stefan L: "Working with exponents in code"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Michael Voss: "Re: Trying to print batch of PDF files programmatically"
- Previous message: Carlos J. Quintero [.NET MVP]: "Re: Newbie Question: Commented Code"
- In reply to: Stefan L: "Working with exponents in code"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|