Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   How does one raise an integer to a power? (http://www.velocityreviews.com/forums/t301746-how-does-one-raise-an-integer-to-a-power.html)

Steve Kershaw 07-11-2006 03:17 AM

How does one raise an integer to a power?
 
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


Steve Kershaw 07-11-2006 03:31 AM

Re: How does one raise an integer to a power?
 
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



Manohar Kamath 07-11-2006 03:54 AM

Re: How does one raise an integer to a power?
 
Math.Pow(x, y)

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


"Steve Kershaw" <steve_kershaw@yahoo.com> wrote in message
news:1152587851.534875.156600@s13g2000cwa.googlegr 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
>




Juan T. Llibre 07-11-2006 11:03 AM

Re: How does one raise an integer to a power?
 
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" <mkamath@REMOVETHISkamath.com> wrote in message
news:%23HT792JpGHA.2400@TK2MSFTNGP03.phx.gbl...
> Math.Pow(x, y)
>
> --
> Manohar Kamath
> Editor, .netBooks
> www.dotnetbooks.com
>
>
> "Steve Kershaw" <steve_kershaw@yahoo.com> wrote in message
> news:1152587851.534875.156600@s13g2000cwa.googlegr 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
>>

>
>




=?Utf-8?B?RGF2aWQgQW50b24=?= 07-11-2006 02:33 PM

RE: How does one raise an integer to a power?
 
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
>
>


clintonG 07-12-2006 04:33 PM

Re: How does one raise an integer to a power?
 
Which is where it should be.

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


"David Anton" <DavidAnton@discussions.microsoft.com> wrote in message
news:F48F9C0C-77D9-432D-A7B8-2E30920528D9@microsoft.com...
> 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
>>
>>




=?Utf-8?B?RGF2aWQgQW50b24=?= 07-14-2006 04:00 PM

Re: How does one raise an integer to a power?
 
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" <DavidAnton@discussions.microsoft.com> wrote in message
> news:F48F9C0C-77D9-432D-A7B8-2E30920528D9@microsoft.com...
> > 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
> >>
> >>

>
>
>


Michael sJR 10-26-2012 08:13 PM

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.

Michael sJR 10-26-2012 08:18 PM

Also, using a function for a basic operation such as or is extremely inefficient because of function call overhead


All times are GMT. The time now is 10:25 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.