Encoding and display The character exists in many computer character sets, usually at 38 (26hex) from
ASCII.
Unicode provides the following variants: • • • • • • • • • • The last six of these are carryovers from the
Wingdings fonts, and are meant only for backward compatibility with those fonts. On the
QWERTY keyboard layout, the ampersand is . It is almost always available on keyboard layouts, sometimes on or . On the
AZERTY keyboard layout, is an unmodified keystroke, positioned above .
Programming languages In the 20th century, following the development of
formal logic, the ampersand became a commonly used logical notation for the
binary operator or
sentential connective AND. This usage was adopted in computing. Many languages with syntax derived from
C, including
C++,
Perl,,
Python, and more differentiate between: • for
bitwise AND is zero, is 4. • for
short-circuit logical AND is true. In
C,
C++,
Rust and
Go, a prefix is a unary operator denoting the
address in memory of the argument, e.g. . In
C++ and
PHP, unary prefix before a
formal parameter of a
function denotes
pass-by-reference. In
Pascal, the as the first character of an identifier prevents the compiler from treating it as a keyword, thus
escaping it. In
Fortran, the ampersand forces the compiler to treat two lines as one. This is accomplished by placing an ampersand at the end of the first line and at the beginning of the second line. In many implementations of
ALGOL 60 the ampersand denotes the tens exponent of a real number. In
Common Lisp, the ampersand is the prefix for
lambda list keywords. Ampersand is the
string concatenation operator in many
BASIC dialects,
AppleScript,
Lingo,
HyperTalk, and
FileMaker. In
Ada it applies to all one-dimensional arrays, not just strings.
BASIC-PLUS on the
DEC PDP-11 uses the ampersand as a short form of the verb .
Applesoft BASIC used the ampersand as an internal command, not intended to be used for general programming, that invoked a
machine language program in the computer's
ROM. In some versions of BASIC, unary suffix & denotes a variable is of type
long, or 32
bits in length. The ampersand was occasionally used as a prefix to denote a
hexadecimal number, such as for decimal 255, for instance in
BBC BASIC. (The modern convention is to use "x" as a prefix to denote hexadecimal, thus .) Some other languages, such as the
Monitor built into ROM on the
Commodore 128, used it to indicate
octal instead, a convention that spread throughout the Commodore community and is now used in the
VICE emulator. In
MySQL, has dual roles. As well as a logical AND, it serves as the bitwise operator of an intersection between elements.
Dyalog APL uses ampersand similarly to
Unix shells, spawning a separate
green thread upon application of a function. In more recent years, the ampersand has made its way into the
Haskell standard library, representing flipped
function application: means the same thing as .
Perl uses the ampersand as a
sigil to refer to subroutines: • In Perl 4 and earlier, it was effectively required to call user-defined subroutines • In Perl 5, it can still be used to modify the way user-defined subroutines are called • In
Raku (formerly known as Perl 6), the ampersand
sigil is only used when referring to a subroutine as an object, never when calling it In the
Xbase family of languages, which includes
dBase and
FoxPro, a singe ampersand signifies macro substitution (where elements of program code are stored in a variable for evaluation at run time). A pair of consecutive ampersands marks the start of an in-line comment. In MASM 80x86 Assembly Language, is the Substitution Operator, which tells the assembler to replace a macro parameter or text macro name with its actual value. Ampersand is the name of a reactive programming language, which uses
relation algebra to specify
information systems.
Text markup In
SGML,
XML, and
HTML, the ampersand is used to introduce an
SGML entity, such as (for non-breaking space) or (for the Greek letter α). The HTML and XML encoding for the ampersand character is the entity . This can create a problem known as
delimiter collision when converting text into one of these markup languages. For instance, when putting URLs or other material containing ampersands into XML format files such as
RSS files the & must be replaced with & or they are considered not well formed, and computers will be unable to read the files correctly. SGML derived the use from
IBM Generalized Markup Language, which was one of many IBM-mainframe languages to use the ampersand to signal a text substitution, eventually going back to
System/360 macro assembly language. In the plain
TeX markup language, the ampersand is used to mark
tabstops. The ampersand itself can be applied in TeX with . The
Computer Modern fonts replace it with an "E.T." symbol in the (text italic) fonts, so it can be entered as {{code|{\it\&} }} in running text when using the default (Computer Modern) fonts. In
Microsoft Windows menus, labels, and other captions, the ampersand is used to denote the next letter as a keyboard shortcut (called an "Access key" by Microsoft). (but not WPF, which uses underscore for this purpose) and is also copied into many other toolkits on multiple operating systems. Sometimes this causes problems similar to other programs that fail to sanitize markup from user input, for instance
Navision databases have trouble if this character is in either "Text" or "Code" fields.
Unix shells Some Unix shells use the ampersand as a
metacharacter: Some Unix shells, like the
POSIX standard sh shell, use an ampersand to
execute a process in the background and to duplicate
file descriptors. • In
Bash, the ampersand can separate words, control the command history, duplicate file descriptors, perform logical operations, control jobs, and participate in
regular expressions.
Web standards The generic
URL (Uniform Resource Locator) syntax allows for a
query string to be appended to a file name in a web address so that additional information can be passed to a script; the
question mark, or query mark, , is used to indicate the start of a query string. A query string is usually made up of a number of different
name–value pairs, each separated by the ampersand symbol, . For example, . A "real" ampersand must be replaced by %26 to avoid interpretation as this syntax. ==Typeface samples==