Exponentiation - in Programming Languages

In Programming Languages

The superscript notation xy is convenient in handwriting but inconvenient for typewriters and computer terminals that align the baselines of all characters on each line. Many programming languages have alternate ways of expressing exponentiation that do not use superscripts:

  • x ↑ y: Algol, Commodore BASIC
  • x ^ y: BASIC, J, MATLAB, R, Microsoft Excel, TeX (and its derivatives), TI-BASIC, bc (for integer exponents), Haskell (for nonnegative integer exponents), Lua, ASP and most computer algebra systems
  • x ^^ y: Haskell (for fractional base, integer exponents), D
  • x ** y: Ada, Bash, COBOL, Fortran, FoxPro, Gnuplot, OCaml, Perl, PL/I, Python, Rexx, Ruby, SAS, Seed7, Tcl, ABAP, Haskell (for floating-point exponents), Turing, VHDL
  • x⋆y: APL

Many programming languages lack syntactic support for exponentiation, but provide library functions.

In Bash, C, C++, C#, Java, JavaScript, Perl, PHP, Python and Ruby, the symbol ^ represents bitwise XOR. In Pascal, it represents indirection. In OCaml and Standard ML, it represents string concatenation.

Read more about this topic:  Exponentiation

Famous quotes containing the words programming and/or languages:

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)

    People in places many of us never heard of, whose names we can’t pronounce or even spell, are speaking up for themselves. They speak in languages we once classified as “exotic” but whose mastery is now essential for our diplomats and businessmen. But what they say is very much the same the world over. They want a decent standard of living. They want human dignity and a voice in their own futures. They want their children to grow up strong and healthy and free.
    Hubert H. Humphrey (1911–1978)