Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / C Question

Author
Message
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 19th Aug 2003 16:55
Just wondering if anyone know the Exponential/Power of Operator for C or C++, Perl is typically ** and naturally I thought it was the same until recently I've been proven incorrect. Anyone know the correct operator? Thanks.
"Computers are useless they can only give you answers."
actarus
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: 32 Light Years away
Posted: 19th Aug 2003 17:12 Edited at: 19th Aug 2003 17:12
Maybe is it '*'

If I've seen it all before,why's this bus taking me back again? @_@
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 19th Aug 2003 17:26
No, * is multiply, the to the power of function is contained it the <math.h> or the <cmath> library (dependant on your c++ compiler) and the command is pow(value, power) so pow(3, 4) would give 3 to the power of 4 which is 81. Hope this helps.

Cheers,
Kentaree

Whatever I did I didn't do it!
actarus
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: 32 Light Years away
Posted: 19th Aug 2003 17:27
I wasn't expecting to be right

If I've seen it all before,why's this bus taking me back again? @_@
Shock
AGK Developer
22
Years of Service
User Offline
Joined: 24th Oct 2002
Location: United Kingdom
Posted: 19th Aug 2003 22:56
hmm, i always thought it was ^

then again ive never had to use it


Sticking feathers up your butt doesn't make you a chicken.
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 20th Aug 2003 05:18
Yea, I always though it was ^. That's what it is for db isn't it? Well, its worth a try.



A book? I hate book. Book is stupid.
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 20th Aug 2003 06:48
depends what your doing...
x^y is standard maths for ALL languages because its the standard mathematics not programming operator.
you can also use y=exp(x) but that is just exponencial of 2 or squared.

John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 20th Aug 2003 06:50
Raven where were you!

Current Project: Eternal Destiny
Porting all files to my new computer
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 20th Aug 2003 10:33
Quote: "No, * is multiply, the to the power of function is contained it the <math.h> or the <cmath> library (dependant on your c++ compiler) and the command is pow(value, power) so pow(3, 4) would give 3 to the power of 4 which is 81. Hope this helps."

Thanks, that works

Oh and ^ is for most calculators and like Raven said, is used for Mathematics but unfortunately I'm yet to see a programming language use it as the exponential operator (except DB(P))

"Computers are useless they can only give you answers."
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 20th Aug 2003 13:58
i've yet to see a programming language that doesn't...

BB uses it, PureBasic uses it, iBasic uses it, C uses it, C++ uses it, Pascal uses it, Fortran uses it, Cobol uses it - its only the extremely basic languages that don't.

Rob K
Retired Moderator
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 20th Aug 2003 14:14 Edited at: 20th Aug 2003 14:16
@Raven

The ^ operator doesn't do exponential in Pascal

The ^ operator is used to dereference a pointer.

In Delphi there is a Power function - Power(3,3) will return 27.

The ^ operator does work in all BASICs AFAIK though.

DSG
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Hampshire, England
Posted: 21st Aug 2003 03:34
The '^' operator performs a bitwise XOR in C/C++.

Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 22nd Aug 2003 12:55
^ doesn't work for the following either:

Visual Basic
PHP
Perl
ASP

o_O

"Computers are useless they can only give you answers."
Shock
AGK Developer
22
Years of Service
User Offline
Joined: 24th Oct 2002
Location: United Kingdom
Posted: 24th Aug 2003 14:23
na, c is easy. well, so long as you don't try and do something difficult.

i learnt how to do a couple of things in c (in dos), like making text adventure games, or very simple text editors with windows style buttons, etc. just don't expect to make anything better than that within half a year of learning it. certainly don't expect to create 3d shoot em ups

i got bored of c after a while, because i couldnt really go any further than the text advernture games (maybe i could if i used visual c++ or something similar, for windows), so i went on the hunt for a programming lingo that would let me do great stuff very easy.

hence i ended up here. i can tell you something, after learning the basics of c, if you then learn dbc, you'd end up learning how to make a first person shooter within a day. i made my first fps within about 8 hours of getting dbc through the door


Sticking feathers up your butt doesn't make you a chicken.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 24th Aug 2003 16:59
Console C++ is fairly easy but once you get into Win32 it starts to get a bit trickier. Then harder still with OpenGL/Direct3D.

"Computers are useless they can only give you answers."

Login to post a reply

Server time is: 2024-11-23 17:22:54
Your offset time is: 2024-11-23 17:22:54