Results 1 to 5 of 5

Thread: Exponents/powers

  1. #1

    Thread Starter
    Lively Member deranged's Avatar
    Join Date
    Jun 2004
    Location
    TN
    Posts
    104

    Exponents/powers

    How do you do Exponents/Powers in C#?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Exponents/powers

    You can use the exponent operator "^" or you can use the Math.Pow method. The difference is that the exponent operator can only be used with integers while either or both values can be fractional with Math.Pow.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Exponents/powers

    Oops! I'm thinking VB.NET. "^" has a different meaning in C#. I'm sure there must be an exponent operator but I don't know what it is. Anyway, you can definitely use Math.Pow.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Exponents/powers

    Quote Originally Posted by jmcilhinney
    I'm sure there must be an exponent operator
    Or maybe not. I just checked the C# Reference in the help and there appears to be no exponent operator. Maybe that's why the Math.Pow method exists. Chalk one up for VB.NET.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Exponents/powers

    In C# "^" is the XOR operator. Math.Pow is indeed the preferred method.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width