4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 That fool 'Carat' operator!
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Poll :: Do you remember what the ^ operator stands for in Perl?

Extends your pattern's legibility by permitting whitespace and comments.
20%
 20%  [ 1 ]
Matches a non-digit character
0%
 0%  [ 0 ]
Quotes the next metacharacter
0%
 0%  [ 0 ]
Updates your address book w/ Larry Wall's e-mail address
40%
 40%  [ 2 ]
Form feed
0%
 0%  [ 0 ]
Matches the beginning of the line
40%
 40%  [ 2 ]
Treats string as single line
0%
 0%  [ 0 ]
Changes the word furniture into the word Furniture
0%
 0%  [ 0 ]
Total Votes : 5


Author Message
verto
Senior WebHelper
Senior WebHelper


Joined: 14 Jan 2002
Posts: 220
Location: Cambridge MA USA

PostPosted: Wed Jul 03, 2002 6:55 pm (15 years, 5 months ago) Reply with QuoteBack to Top

I couldn't find a better place to post this (such as a board for a specific language) because I don't know the answer to my question yet, doh! Embarassed Wink Confused Cool

On a JavaScript certification test I've taken a few times, i noticed I kept missing various questions related to the 'carat' operator (i.e., ^ ). In JavaScript, it's used for XOR bitwise operations (logical 'exclusive' OR), but something in me kept wanting to use it as a 'power' (exponentiation) operator (i.e., x ^ y = x to the yth power).

I've finally gotten the ^ somewhat firmly associated w/ XOR in JavaScript, but can't, for the life of me, remember in which (if any) language it's used for exponentiation. I tried searching online for its usage in different languages for exponentiation, but it's taking too long I'm afraid. So far, I've found it used for XOR in C ... Sad Embarassed Crying or Very sad Laughing

There must be some programmers out there who already know/remember this! Wink Smile

________________________________
>>>>>>>>>>>>>
GENERAL DISCLAIMER:This disclaimer may be void where null in all cases unless explicitly not unprohibited or (p)re-exclusively assigned by sufficient presedimentation on behalf of every non-interested party to wit (or so it was said).
:::
.: :. . : :....: :.: .: :. verto .: :. . : :....: :.: .: :.


Last edited by verto on Fri Jul 05, 2002 8:59 pm, edited 1 time in total
OfflineView User's ProfileFind all posts by vertoSend Personal Message
general-chat.com
Junior WebHelper
Junior WebHelper


Joined: 25 Jun 2002
Posts: 10
Location: uk

PostPosted: Wed Jul 03, 2002 10:04 pm (15 years, 5 months ago) Reply with QuoteBack to Top

what are u on about me confussed Crying or Very sad Sad Shocked

________________________________
[http://www.general-chat.com] please come join me.
OfflineView User's ProfileFind all posts by general-chat.comSend Personal MessageSend emailVisit Poster's WebsiteMSN Messenger
Garth Farley
WebHelper
WebHelper


Joined: 08 Jan 2002
Posts: 69
Location: Ireland

PostPosted: Thu Jul 04, 2002 12:42 am (15 years, 5 months ago) Reply with QuoteBack to Top

Well I can confirm that it isn't used by Perl or PHP or C or C++ or Java.

Yeah this is beginning to get to me too.

By the way, as the Mathematician that I am, I must clarify the difference betweem exponentiation and power. Exponent is 3 X 10**-4. Power is simply 3**-4

Where ** stands for power of.

Garth Farley
OfflineView User's ProfileFind all posts by Garth FarleySend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Thu Jul 04, 2002 8:50 am (15 years, 5 months ago) Reply with QuoteBack to Top

Well, actually, I'm sure I've seen ^ used in Perl scripts... Smile

For example, when you configure an email address in FormMail, there's a ^ in front of it.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Garth Farley
WebHelper
WebHelper


Joined: 08 Jan 2002
Posts: 69
Location: Ireland

PostPosted: Thu Jul 04, 2002 11:44 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Daniel wrote:
Well, actually, I'm sure I've seen ^ used in Perl scripts... Smile


Oh yeah, the carat is used for XORing bits in a few languages, as well as Perl RegExps.

Garth Farley
OfflineView User's ProfileFind all posts by Garth FarleySend Personal Message
verto
Senior WebHelper
Senior WebHelper


Joined: 14 Jan 2002
Posts: 220
Location: Cambridge MA USA

PostPosted: Fri Jul 05, 2002 2:45 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Garth wrote:
"Oh yeah, the carat is used for XORing bits in a few languages, as well as Perl RegExps."

Well you're right on that, and thanks for the bit about exponentiation (i'm beginning to think that this's maybe one reason i never felt right about logarithms when i took math in High School -- i never really got down the differences in all the terminology. Sure, logs are really the same as exponents -- or are they? Embarassed Crying or Very sad Laughing )

i think i got the answer i was looking for at another site where i posted this. The server for it's down at the moment, so i can't post the replies, but one was to the effect that ^ is used for power ops in sed and VBS (which i think maybe is the same as VBScript?).

Some of my earliest programming was done in a version of Quick Basic that Microsoft sold as an IDE back in the mid-80's before they started bundling a pared-down version of it with MS-DOS, and i'm still guessing that this's where i got that usage from. I haven't confirmed this yet for Quick Basic or Sed (which i think actually uses it in RegExps in same way as Perl), but here's what i found online for VBScript:

Quote:
"The ^ operator, which is sometimes called "hat", is used to raise a number to a power."

________________________________
>>>>>>>>>>>>>
GENERAL DISCLAIMER:This disclaimer may be void where null in all cases unless explicitly not unprohibited or (p)re-exclusively assigned by sufficient presedimentation on behalf of every non-interested party to wit (or so it was said).
:::
.: :. . : :....: :.: .: :. verto .: :. . : :....: :.: .: :.
OfflineView User's ProfileFind all posts by vertoSend Personal Message
Garth Farley
WebHelper
WebHelper


Joined: 08 Jan 2002
Posts: 69
Location: Ireland

PostPosted: Wed Jul 10, 2002 9:18 pm (15 years, 5 months ago) Reply with QuoteBack to Top

I thought that was ** in Perl and PHP. Not C anyway, it needs the pow() function. No idea about Java. So it must be different for each language.

Garth Farley
OfflineView User's ProfileFind all posts by Garth FarleySend Personal Message
verto
Senior WebHelper
Senior WebHelper


Joined: 14 Jan 2002
Posts: 220
Location: Cambridge MA USA

PostPosted: Fri Jul 12, 2002 11:28 pm (15 years, 5 months ago) Reply with QuoteBack to Top

well thanks for thinking about it, Garth Smile

________________________________
>>>>>>>>>>>>>
GENERAL DISCLAIMER:This disclaimer may be void where null in all cases unless explicitly not unprohibited or (p)re-exclusively assigned by sufficient presedimentation on behalf of every non-interested party to wit (or so it was said).
:::
.: :. . : :....: :.: .: :. verto .: :. . : :....: :.: .: :.
OfflineView User's ProfileFind all posts by vertoSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.056599 seconds :: 19 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme