What are the ^ and | symbols on the keyboard?

Community Forums/General Help/What are the ^ and | symbols on the keyboard?

Captain Wicker (crazy hillbilly)(Posted 2012) [#1]
Hello,

The many years me and my classmates have taken the dreaded keyboarding course, We never learned what the ^ and | symbols meant. Can someone please tell me what these symbols on the keyboard are used for and what they mean?


TaskMaster(Posted 2012) [#2]
This one "^" is a caret and is used for math. 2^2 is 2 to the power of 2, like 2 squared, this would be 3 squared 3^2, etc...

This "|" is a pipe character. It can used for some math, or redirecting output on the command line, or some other uses...


Captain Wicker (crazy hillbilly)(Posted 2012) [#3]
Thanks TaskMaster, that really helps out! :)


Yasha(Posted 2012) [#4]
If you want to get technical... they're a bent line and a straight line, and they mean whatever you want.

No, seriously. Glyphs have very little inherent meaning. But 99% of the time TaskMaster's explanation stands (the exception is in C and C-derived programming where ^ means Xor and | means bitwise-Or).


xlsior(Posted 2012) [#5]
The ^ is pronounced 'caret', or 'circumflex' when used as a diacritic which modifies another letter.
the | is pronounced 'pipe'

http://en.wikipedia.org/wiki/Caret
http://en.wikipedia.org/wiki/Circumflex

Other uses:

the '^' is also used as a shorthand for the 'control'-key... So instead of 'control-C', you may see it written as ^C

In some languages, the ^ (circumflex) is used as a modifier for other characters... For example, in French you may see the letter 'o' written as o with the little ^ on top of it. In some keyboard entry modes, you can type that character by typing the ^ first and then the letter o, and it will automatically be replaced by the o-with-^ as a single character.

The ^ is used in mathematic notations to indicate a 'power of'. 2^3 = 8

The | is often used as a field seperator in electrinic text files -- for example, it's an easy way of storing data in delimited columns:

Bob|O'Brian|418 Main Street, apt. C|Anytown|optional|optional|required
Joe|Lastname|101 Test Drive|Othertown|||required


If you read that data file on a computer, you know exactly when the next field is supposed to start, without having to be afraid that it's a 'real' character. For example, using a space as a delimiter would screw up in fields that use one or more spaces. Using a , would screw up some extended addresses. Using a ' would screw up with certain last names, etc. Since the | has no 'normal' alphanumeric use, it's often used as a safe delimiters. It's on all keyboards, so much easier to use than other random ASCII values.
All in all, more useful and safer than 'CSV' (comma seperated values)

The | is also used as a command seperator -- under Unix/Linux/DOS you can 'chain' multiple commands with the | character, like this:

dir /b/s | more


Which would run the 'dir' command, but instead of printing everything straight to the screen, it redirects it as input to the 'more' command, which will print it to the screen and then wait for user input to proceed when the screen is full.

You can chain a whole bunch of these in a row, and have the output of the chain redirected down the path, each doing additional modifications before passing it on to the next.

dir /b/s | grep -v EE | grep .exe | more


And ironically, under DOS/Windows, the ^ has another special use related to other special characters like the |. The ^ acts as a so-called escape character. For example: if I want to type a file from the command line and return all lines that contain a specific character, you'd normally do this:
(requires the 'grep' command line tool)

type myfile.txt | grep A


Which works fine, and returns all lines with the letter A.

However, if you want to return all lines that contain the | character, you CAN'T do this:

type myfile.txt | grep |


...because it looks like you're chaining it to another non-specified program, and the command will error out.

Instead, DOS uses the ^ as an 'escape' character:

type myfile.txt | grep ^|   | more


...which will tell it to the take the character after the ^ to be interpreted literally as a parameter instead of as a command seperator.

Look for any line containing ||| in a row?

type myfile.txt | grep ^|^|^|  | more



Floyd(Posted 2012) [#6]
the exception is in C and C-derived programming where ^ means Xor

That one has always annoyed me. In the notation of mathematical logic ^ is the symbol for And.

Even if I got my wish for ^ to mean And things still wouldn't work out. An upside down ^ is the symbol for Or. But it's not on our keyboards.


therevills(Posted 2012) [#7]
But it's not on our keyboards.

Yes it is! Turn your keyboard upside down... done :)

[Steve grabs his coat and heads for the door...]


Kryzon(Posted 2012) [#8]
For those with double-language Windows, holding ALT + SHIFT changes the language of the keyboard input.

If you tend to write in two languages this is very useful. Sometimes you need a special symbol that only one of the sets has (i.e cedilla in one set, interrogation mark in another).


SystemError51(Posted 2012) [#9]
The pipe is also often used to combine parameters in programming languages, as well as being an "OR" condition.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)


I had this in C and Objective-C:

If (test_result > 30.0 | test_result < 15.0)


Last edited 2012


Pengwin(Posted 2012) [#10]
The pipe is also often used to combine parameters in programming languages, as well as being an "OR" condition.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)


I had this in C and Objective-C:

If (test_result > 30.0 | test_result < 15.0)


Technically, what you are doing there is ORing the values together, so the definition of | meaning OR still stands