Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How does one raise an integer to a power?

Reply
Thread Tools

How does one raise an integer to a power?

 
 
Steve Kershaw
Guest
Posts: n/a
 
      07-11-2006
This is stupid!!!!

I have looked everywhere (in books, google, online....) to find out how
to raise a number to a power and I can't find it!!!

For example:

given x = 10
y = x ^ 2;
y would then be 100 (10 squared is 100).

Why can't I find such a basic operation!?

Steve

 
Reply With Quote
 
 
 
 
Steve Kershaw
Guest
Posts: n/a
 
      07-11-2006
Sorry,

I need this in C#

Steve


Steve Kershaw wrote:
> This is stupid!!!!
>
> I have looked everywhere (in books, google, online....) to find out how
> to raise a number to a power and I can't find it!!!
>
> For example:
>
> given x = 10
> y = x ^ 2;
> y would then be 100 (10 squared is 100).
>
> Why can't I find such a basic operation!?
>
> Steve


 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      07-11-2006
Math.Pow(x, y)

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com


"Steve Kershaw" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> This is stupid!!!!
>
> I have looked everywhere (in books, google, online....) to find out how
> to raise a number to a power and I can't find it!!!
>
> For example:
>
> given x = 10
> y = x ^ 2;
> y would then be 100 (10 squared is 100).
>
> Why can't I find such a basic operation!?
>
> Steve
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      07-11-2006
It might be useful to point out that the x stands for the number
to be raised and that the y stands for the power to which the x is raised.

i.e., the return value of Math.Pow(x, y) is the number x raised to the power y.

http://msdn2.microsoft.com/en-us/lib....math.pow.aspx



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Manohar Kamath" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Math.Pow(x, y)
>
> --
> Manohar Kamath
> Editor, .netBooks
> www.dotnetbooks.com
>
>
> "Steve Kershaw" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> This is stupid!!!!
>>
>> I have looked everywhere (in books, google, online....) to find out how
>> to raise a number to a power and I can't find it!!!
>>
>> For example:
>>
>> given x = 10
>> y = x ^ 2;
>> y would then be 100 (10 squared is 100).
>>
>> Why can't I find such a basic operation!?
>>
>> Steve
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      07-11-2006
Unlike VB, C# has no exponentiation operator built into the language. You
have to use the Math class (Math.Pow).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#


"Steve Kershaw" wrote:

> This is stupid!!!!
>
> I have looked everywhere (in books, google, online....) to find out how
> to raise a number to a power and I can't find it!!!
>
> For example:
>
> given x = 10
> y = x ^ 2;
> y would then be 100 (10 squared is 100).
>
> Why can't I find such a basic operation!?
>
> Steve
>
>

 
Reply With Quote
 
clintonG
Guest
Posts: n/a
 
      07-12-2006
Which is where it should be.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


"David Anton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Unlike VB, C# has no exponentiation operator built into the language. You
> have to use the Math class (Math.Pow).
> --
> David Anton
> www.tangiblesoftwaresolutions.com
> Instant C#: VB to C# converter
> Instant VB: C# to VB converter
> Instant C++: C#/VB to C++ converter
> C# Code Metrics: Quick metrics for C#
>
>
> "Steve Kershaw" wrote:
>
>> This is stupid!!!!
>>
>> I have looked everywhere (in books, google, online....) to find out how
>> to raise a number to a power and I can't find it!!!
>>
>> For example:
>>
>> given x = 10
>> y = x ^ 2;
>> y would then be 100 (10 squared is 100).
>>
>> Why can't I find such a basic operation!?
>>
>> Steve
>>
>>



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      07-14-2006
Using that same argument you could say that we should also have Logical.Or
instead of || and Math.Multiply instead of *. It's debatable what should be
built in operators and what shouldn't.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#


"clintonG" wrote:

> Which is where it should be.
>
> <%= Clinton Gallagher
> NET csgallagher AT metromilwaukee.com
> URL http://www.metromilwaukee.com/clintongallagher/
>
>
> "David Anton" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Unlike VB, C# has no exponentiation operator built into the language. You
> > have to use the Math class (Math.Pow).
> > --
> > David Anton
> > www.tangiblesoftwaresolutions.com
> > Instant C#: VB to C# converter
> > Instant VB: C# to VB converter
> > Instant C++: C#/VB to C++ converter
> > C# Code Metrics: Quick metrics for C#
> >
> >
> > "Steve Kershaw" wrote:
> >
> >> This is stupid!!!!
> >>
> >> I have looked everywhere (in books, google, online....) to find out how
> >> to raise a number to a power and I can't find it!!!
> >>
> >> For example:
> >>
> >> given x = 10
> >> y = x ^ 2;
> >> y would then be 100 (10 squared is 100).
> >>
> >> Why can't I find such a basic operation!?
> >>
> >> Steve
> >>
> >>

>
>
>

 
Reply With Quote
 
Michael sJR Michael sJR is offline
Junior Member
Join Date: Oct 2012
Posts: 2
 
      10-26-2012
Not necessarily... In computer science, powers aren't a basic operation. In fact, they require careful logic and could easily be ineffient. This logic should be placed in a function so software engineers can see the source code and calculate the complexity should they decide to implement a better version.
 
Reply With Quote
 
Michael sJR Michael sJR is offline
Junior Member
Join Date: Oct 2012
Posts: 2
 
      10-26-2012
Also, using a function for a basic operation such as or is extremely inefficient because of function call overhead
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Raise X or Raise X()? bvdp Python 10 03-12-2012 04:08 PM
"raise (type, value, traceback)" and "raise type, value, traceback" Jack Bates Python 0 05-02-2011 05:23 PM
raise Exception or raise Exception() ernest Python 2 11-14-2010 08:14 PM
raise or not to raise [Newbie] Jacol Python 5 02-05-2007 11:46 PM



Advertisments