Caret (computing)
^ | |
---|---|
Caret (computing) | |
In Unicode | U+005E ^ CIRCUMFLEX ACCENT (HTML ^ · ^) |
Different from | |
Different from | U+2038 ‸ CARET U+02C6 ˆ MODIFIED LETTER CIRCUMFLEX ACCENT U+028C ʌ LATIN SMALL LETTER TURNED V U+2227 ∧ LOGICAL AND U+039B Λ GREEK CAPITAL LETTER LAMDA |
In computing, the caret, also known as circumflex, is the character ^.
Origin and representation[edit]
The original meaning of the word caret is a symbol used to indicate where a punctuation mark, word, or phrase should be inserted into a document. Initially, the symbol was included in typewriters and computer printers so that circumflex accents could be overprinted on letters (as in ô or ŵ). Later, the character became reused in computer languages for many other purposes, and over time its appearance was enlarged and lowered, making it unusable as an accent mark.
In Unicode it is encoded as U+005E ^ CIRCUMFLEX ACCENT and in HTML may be inserted with &hat;
.
This caret is not to be confused with other chevron-shaped characters, such as the turned v or the logical AND, which may occasionally be called carets.[1][2]
Uses[edit]
Programming languages[edit]
The caret ^ has many uses in programming languages, where it is typically called a caret. It can signify exponentiation, the bitwise XOR operator, string concatenation, and control characters in caret notation, among other uses. In regular expressions, the caret is used to match the beginning of a string or line; if it begins a character class, then the inverse of the class is to be matched.
ANSI C can transcribe the caret in the form of the trigraph ??'
, as the character was originally not available in all character sets and keyboards.
C++ additionally supports tokens like xor
(for ^
) and xor_eq
(for ^=
) to avoid the character altogether.
RFC 1345 recommends to transcribe the character as digraph '>
when required.[3]
Pascal uses the caret for declaring and dereferencing pointers.
In Smalltalk, the caret is the method return statement.
In C++/CLI, .NET reference types are accessed through a handle using the ClassName^
syntax.
In Apple's C extensions for Mac OS X and iOS, carets are used to create blocks and to denote block types.
Go uses it as a bitwise NOT operator.
Node.js uses the caret in package.json files to signify dependency resolution behavior being used for each particular dependency. In the case of Node.js, a caret allows any kind of update, unless it is seen as a "major" update as defined by semver.[4]
Surrogate symbol for superscript and exponentiation[edit]
In mathematics, the caret can signify exponentiation (3^5
for 35), where the usual superscript is not readily usable (as on some graphing calculators). It is also used to indicate a superscript in TeX typesetting. As Isaac Asimov described it in his 1974 "Skewered!" essay (on Skewes' number), "I make the exponent a figure of normal size and it is as though it is being held up by a lever, and its added weight when its size grows bends the lever down."[5] The use of the caret for exponentiation can be traced back to ALGOL 60,[citation needed] which expressed the exponentiation operator as an upward-pointing arrow, intended to evoke the superscript notation common in mathematics. The upward-pointing arrow is now used to signify hyperoperations in Knuth's up-arrow notation.
Escape character[edit]
Often seen as caret notation to show control characters, for instance ^A
means the control character with value 1.
The command-line interpreter, cmd.exe, of Windows uses the caret to escape reserved characters (most other shells use the backslash). For instance to pass a less-than sign as an argument to a program you type ^<
.
Ordinal indicator[edit]
![]() | This section needs to be updated.(May 2020) |
In Italian, the caret is sometimes used in a similar manner to the ordinal indicator, most noticeably on tickets from Trenitalia, the primary operator of trains within Italy, and Rome's ATAC public transit system. On Trenitalia tickets, the travel class is often written as 1^ or 2^, meaning first class or second class respectively.[citation needed] This is due to the lack of ordinal indicators in ASCII.
Upwards-pointing arrow[edit]
In internet forums, social networking sites such as Facebook, or in online chats, one or more carets may be used beneath the text of another post, representing an upwards-pointing arrow to that post.[6] In addition to the arrow usage, it can also mean that the user who posted the ^ agrees with the above post. Multiple caretss may indicate the comment is replying to or relating to the post above that correlates with the number of carets used, or to "underscore" the correct portion of the previous post, or may simply be used for emphasis.
A similar use has been adopted by programming language compilers such as Java compiler to point out where a compilation error has occurred.[citation needed] The compiler prints out the faulty line of code and uses a single caret on the next line, padded by spaces, to give a visual indication of the error location.
History[edit]
The original 1963 version of the ASCII standard used the code point 5Ehex for an up-arrow ↑. However, the 1965 ECMA-6 standard replaced the up-arrow with circumflex ^ diacritic and in 1967, the second revision of ASCII followed suit.[7] As the early mainframes and minicomputers largely used teleprinters as output devices, it was possible to print the circumflex above a letter when needed. With the proliferation of monitors, however, this often was impossible, and precomposed characters with the diacritic included, such as Latin-1, were necessary to show the accented letters. The original circumflex character was left for other purposes, and as it did not need to fit above a letter anymore, it became larger in appearance.[8]
See also[edit]
- Caret as used in proofreading and typography
- Hat operator, a notation used in mathematics and statistics, is sometimes called a caret
References[edit]
- ^ Unicode (1991–2012). "IPA Extensions" (PDF). Retrieved 20 August 2012.
- ^ Eric W. Weisstein. "Caret". MathWorld. Wolfram. Retrieved 20 August 2012.
- ^ "RFC 1345 - Character Mnemonics and Character Sets". tools.ietf.org. Retrieved 7 March 2022.
- ^ "Caret ranges in node.js". Archived from the original on 3 December 2016. Retrieved 1 October 2019.
- ^ Isaac Asimov (1974), "Skewered", Of Matters Great and Small, Doubleday, ISBN 978-0385022255
- ^ "What is Caret?". Computer Hope. Retrieved 14 August 2012.
- ^ Tom Jennings. "ASCII: American Standard Code for Information Infiltration". Archived from the original on 21 August 2014. Retrieved 14 September 2010.
- ^ Jukka K. Korpela (18 January 2010). "Kirjainten tarinoita" (PDF) (in Finnish). pp. 132–133. Retrieved 14 September 2010.