Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 3rd, 2006, 2:06 AM   #1
dvu
Newbie
 
Join Date: Jul 2005
Location: Houston. Texas
Posts: 3
Rep Power: 0 dvu is on a distinguished road
How do i use a ^ for a double variable?

I need to raise a double variable to X power.

something like this...

double rate;
double sum;

sum = rate ^ -360;

When i try to compile i get the error "Operator '^' cannot be applied operands of type 'double'.

So how does one take a double to X power?

Sorry if i am hard to understand. Im still very new to this.

TIA
dvu is offline   Reply With Quote
Old Feb 3rd, 2006, 6:23 AM   #2
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
I don't know C#, but I can suggest you either to create your function or overload operator ^ if C# allows that.
ivan is offline   Reply With Quote
Old Feb 3rd, 2006, 7:23 AM   #3
Jason Isom
Programmer
 
Join Date: Dec 2005
Posts: 53
Rep Power: 3 Jason Isom is on a distinguished road
Quote:
Originally Posted by dvu
I need to raise a double variable to X power.

something like this...

double rate;
double sum;

sum = rate ^ -360;

When i try to compile i get the error "Operator '^' cannot be applied operands of type 'double'.

So how does one take a double to X power?

Sorry if i am hard to understand. Im still very new to this.

TIA
Use System.Math.Pow(double x, double y) to calculate x ^ y

The '^' character is a bitwise character for XOR
Jason Isom is offline   Reply With Quote
Old Feb 3rd, 2006, 10:26 AM   #4
dvu
Newbie
 
Join Date: Jul 2005
Location: Houston. Texas
Posts: 3
Rep Power: 0 dvu is on a distinguished road
wow thanks guys. You guys are the best
dvu is offline   Reply With Quote
Old Feb 3rd, 2006, 10:27 AM   #5
java_roshan
Professional Programmer
 
Join Date: Mar 2005
Location: Student of University of Mumbai, Maharashtra State, India
Posts: 344
Rep Power: 4 java_roshan is on a distinguished road
Math.Pow is a static method and can be applied to different data types. Like that, there are many other math methods associated and u can find them at http://msdn.microsoft.com
__________________
Visit: http://www.somaiya.edu
java_roshan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC