473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

Jul 11 '06 #1
6 9670
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
Jul 11 '06 #2
Math.Pow(x, y)

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"Steve Kershaw" <st***********@yahoo.comwrote in message
news:11**********************@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

Jul 11 '06 #3
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" <mk*****@REMOVETHISkamath.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Math.Pow(x, y)

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"Steve Kershaw" <st***********@yahoo.comwrote in message
news:11**********************@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


Jul 11 '06 #4
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

Jul 11 '06 #5
Which is where it should be.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"David Anton" <Da********@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.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


Jul 12 '06 #6
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" <Da********@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.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



Jul 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Helmut Jarausch | last post by:
Hi, what does Python do if two objects aren't comparable (to my opinion) If I've understood "Python in a Nutschell" correctly it should raise an exception but it doesn't do for me. Here are...
11
by: Grant Edwards | last post by:
I've read over and over that Python leaves floating point issues up to the underlying platform. This seems to be largely true, but not always. My underlying platform (IA32 Linux) correctly...
5
by: Thomas LeBlanc | last post by:
I copied an example from the help: CREATE FUNCTION somefunc() RETURNS integer AS ' DECLARE quantity integer := 30; BEGIN RAISE NOTICE ''Quantity here is %'', quantity; -- Quantity here is 30...
2
by: Mauricio Rendon | last post by:
Hi, If I have a Label in a Form and need to raise the MouseUp event on the label to the Form ( Parent Control ), What must I do ? Thanks !!!
3
by: Robin Tucker | last post by:
Does anyone have a VB.NET IPersistStream COM interface description I can cadge please? If I remember rightly, you have to "flatten" inherited COM interfaces (I think IPersistStream derives from...
3
by: abcd | last post by:
this is simple VB question but its not clicking me right now...the code is as below Private Sub Command1_Click() On Error Resume Next MsgBox calculate
19
by: Robbie Hatley | last post by:
For your enjoyment, a function that expresses any integer with absolute value less-than-or-equal-to nine quintillion in any base from 2 to 36. (For larger bases, you could expand the "digit"...
10
by: David T. Ashley | last post by:
What is the most economical test in 'C' for "integer is a power of 2"? For example, something better than: void is_2_pow(int arg) { return((x == 1) || (x == 2) || (x == 4) || (x == 8) || (x...
5
by: ryanwpenfold | last post by:
Hi, The variable _intBlogID changes from -1 to 0 when the Mode_Get method is called. I don't understand why this happens. I included default property values, and that didn't help. I wrote and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.