# Mathematics · The Julia Language
Source: https://docs.julialang.org/en/v1/base/math/


# [Mathematics](#Mathematics)


## [Mathematical Operators](#math-ops)
```julia
-(x)
```
Unary minus operator.
See also: [`abs`](#Base.abs), [`flipsign`](#Base.flipsign).
**Examples**
```julia-repl
julia> -1
-1

julia> -(2)
-2

julia> -[1 2; 3 4]
2×2 Matrix{Int64}:
 -1  -2
 -3  -4

julia> -(true)  # promotes to Int
-1

julia> -(0x003)
0xfffd
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2978-L3004)
```julia
dt::Date + t::Time -> DateTime
```
The addition of a `Date` with a `Time` produces a `DateTime`. The hour, minute, second, and millisecond parts of the `Time` are used along with the year, month, and day of the `Date` to create the new `DateTime`. Non-zero microseconds or nanoseconds in the `Time` type will result in an `InexactError` being thrown.
```julia
+(x, y...)
```
Addition operator.
Infix `x+y+z+...` calls this function with all arguments, i.e. `+(x, y, z, ...)`, which by default then calls `(x+y) + z + ...` starting from the left.
Note that overflow is possible for most integer types, including the default `Int`, when adding large numbers.
**Examples**
```julia-repl
julia> 1 + 20 + 4
25

julia> +(1, 20, 4)
25

julia> [1,2] + [3,4]
2-element Vector{Int64}:
 4
 6

julia> typemax(Int) + 1 < 0
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L2948-L2975)
```julia
-(x, y)
```
Subtraction operator.
**Examples**
```julia-repl
julia> 2 - 3
-1

julia> -(2, 4.5)
-2.5
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3007-L3020)
```julia
*(x, y...)
```
Multiplication operator.
Infix `x*y*z*...` calls this function with all arguments, i.e. `*(x, y, z, ...)`, which by default then calls `(x*y) * z * ...` starting from the left.
Juxtaposition such as `2pi` also calls `*(2, pi)`. Note that this operation has higher precedence than a literal `*`. Note also that juxtaposition "0x..." (integer zero times a variable whose name starts with `x`) is forbidden as it clashes with unsigned integer literals: `0x01 isa UInt8`.
Note that overflow is possible for most integer types, including the default `Int`, when multiplying large numbers.
**Examples**
```julia-repl
julia> 2 * 7 * 8
112

julia> *(2, 7, 8)
112

julia> [2 0; 0 3] * [1, 10]  # matrix * vector
2-element Vector{Int64}:
  2
 30

julia> 1/2pi, 1/2*pi  # juxtaposition has higher precedence
(0.15915494309189535, 1.5707963267948966)

julia> x = [1, 2]; x'x  # adjoint vector * vector
5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3023-L3058)
```julia
/(x, y)
```
Right division operator: multiplication of `x` by the inverse of `y` on the right.
Gives floating-point results for integer arguments. See [`÷`](#Base.div) for integer division, or [`//`](#Base.://) for [`Rational`](../numbers/#Base.Rational) results.
**Examples**
```julia-repl
julia> 1/2
0.5

julia> 4/2
2.0

julia> 4.5/2
2.25
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L3061-L3080)
```julia
A / B
```
Matrix right-division: `A / B` is equivalent to `(B' \ A')'` where [`\`](#Base.:\\-Tuple%7BAny,%20Any%7D) is the left-division operator. For square matrices, the result `X` is such that `A == X*B`.
See also: [`rdiv!`](../../stdlib/LinearAlgebra/#LinearAlgebra.rdiv!).
**Examples**
```julia-repl
julia> A = Float64[1 4 5; 3 9 2]; B = Float64[1 4 2; 3 4 2; 8 7 1];

julia> X = A / B
2×3 Matrix{Float64}:
 -0.65   3.75  -1.2
  3.25  -2.75   1.0

julia> isapprox(A, X*B)
true

julia> isapprox(X, A*pinv(B))
true
```
```julia
\(x, y)
```
Left division operator: multiplication of `y` by the inverse of `x` on the left. Gives floating-point results for integer arguments.
**Examples**
```julia-repl
julia> 3 \ 6
2.0

julia> inv(3) * 6
2.0

julia> A = [4 3; 2 1]; x = [5, 6];

julia> A \ x
2-element Vector{Float64}:
  6.5
 -7.0

julia> inv(A) * x
2-element Vector{Float64}:
  6.5
 -7.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L607-L633)
```julia
^(x, y)
```
Exponentiation operator.
If `x` and `y` are integers, the result may overflow. To enter numbers in scientific notation, use [`Float64`](../numbers/#Core.Float64) literals such as `1.2e3` rather than `1.2 * 10^3`.


## [Mathematical Operators](#math-ops)
If `y` is an `Int` literal (e.g. `2` in `x^2` or `-3` in `x^-3`), the Julia code `x^y` is transformed by the compiler to `Base.literal_pow(^, x, Val(y))`, to enable compile-time specialization on the value of the exponent. (As a default fallback we have `Base.literal_pow(^, x, Val(y)) = ^(x,y)`, where usually `^ == Base.^` unless `^` has been defined in the calling namespace.) If `y` is a negative integer literal, then `Base.literal_pow` transforms the operation to `inv(x)^-y` by default, where `-y` is positive.
See also [`exp2`](#Base.exp2), [`<<`](#Base.:%3C%3C).
**Examples**
```julia-repl
julia> 3^5
243

julia> 3^-1  # uses Base.literal_pow
0.3333333333333333

julia> p = -1;

julia> 3^p
ERROR: DomainError with -1:
Cannot raise an integer x to a negative power -1.
[...]

julia> 3.0^p
0.3333333333333333

julia> 10^19 > 0  # integer overflow
false

julia> big(10)^19 == 1e19
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/promotion.jl#L434-L477)
```julia
fma(x, y, z)
```
Computes `x*y+z` without rounding the intermediate result `x*y`. On some systems this is significantly more expensive than `x*y+z`. `fma` is used to improve accuracy in certain algorithms. See [`muladd`](#Base.muladd).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/floatfuncs.jl#L271-L277)
```julia
muladd(x, y, z)
```


## [Mathematical Operators](#math-ops)
Combined multiply-add: computes `x*y+z`, but allowing the add and multiply to be merged with each other or with surrounding operations for performance. For example, this may be implemented as an [`fma`](#Base.fma) if the hardware supports it efficiently. The result can be different on different machines and can also be different on the same machine due to constant propagation or other optimizations. See [`fma`](#Base.fma).
**Examples**
```julia-repl
julia> muladd(3, 2, 1)
7

julia> 3 * 2 + 1
7
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L1450-L1469)
```julia
muladd(A, y, z)
```
Combined multiply-add, `A*y .+ z`, for matrix-matrix or matrix-vector multiplication. The result is always the same size as `A*y`, but `z` may be smaller, or a scalar.
These methods require Julia 1.6 or later.
**Examples**
```julia-repl
julia> A=[1.0 2.0; 3.0 4.0]; B=[1.0 1.0; 1.0 1.0]; z=[0, 100];

julia> muladd(A, B, z)
2×2 Matrix{Float64}:
   3.0    3.0
 107.0  107.0
```
```julia
inv(x)
```
Return the multiplicative inverse of `x`, such that `x*inv(x)` or `inv(x)*x` yields [`one(x)`](../numbers/#Base.one) (the multiplicative identity) up to roundoff errors.
If `x` is a number, this is essentially the same as `one(x)/x`, but for some types `inv(x)` may be slightly more efficient.
**Examples**
```julia-repl
julia> inv(2)
0.5

julia> inv(1 + 2im)
0.2 - 0.4im

julia> inv(1 + 2im) * (1 + 2im)
1.0 + 0.0im

julia> inv(2//3)
3//2
```
`inv(::Missing)` requires at least Julia 1.2.


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/number.jl#L228-L254)
```julia
div(x, y)
÷(x, y)
```
The quotient from Euclidean (integer) division. Generally equivalent to a mathematical operation x/y without a fractional part.
See also: [`cld`](#Base.cld), [`fld`](#Base.fld), [`rem`](#Base.rem), [`divrem`](#Base.divrem).
**Examples**
```julia-repl
julia> 9 ÷ 4
2

julia> -5 ÷ 3
-1

julia> 5.0 ÷ 2
2.0

julia> div.(-5:5, 3)'
1×11 adjoint(::Vector{Int64}) with eltype Int64:
 -1  -1  -1  0  0  0  0  0  1  1  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L785-L809)
```julia
div(x, y, r::RoundingMode=RoundToZero)
```
The quotient from Euclidean (integer) division. Computes `x / y`, rounded to an integer according to the rounding mode `r`. In other words, the quantity
```julia
round(x / y, r)
```
without any intermediate rounding.
The three-argument method taking a `RoundingMode` requires Julia 1.4 or later.
See also [`fld`](#Base.fld) and [`cld`](#Base.cld), which are special cases of this function.
`RoundFromZero` requires at least Julia 1.9.
**Examples:**


## [Mathematical Operators](#math-ops)
```julia-repl
julia> div(4, 3, RoundToZero) # Matches div(4, 3)
1
julia> div(4, 3, RoundDown) # Matches fld(4, 3)
1
julia> div(4, 3, RoundUp) # Matches cld(4, 3)
2
julia> div(5, 2, RoundNearest)
2
julia> div(5, 2, RoundNearestTiesAway)
3
julia> div(-5, 2, RoundNearest)
-2
julia> div(-5, 2, RoundNearestTiesAway)
-3
julia> div(-5, 2, RoundNearestTiesUp)
-2
julia> div(4, 3, RoundFromZero)
2
julia> div(-4, 3, RoundFromZero)
-2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/div.jl#L5-L46)
```julia
fld(x, y)
```
Largest integer less than or equal to `x / y`. Equivalent to `div(x, y, RoundDown)`.
See also [`div`](#Base.div), [`cld`](#Base.cld), [`fld1`](#Base.fld1).
**Examples**
```julia-repl
julia> fld(7.3, 5.5)
1.0

julia> fld.(-5:5, 3)'
1×11 adjoint(::Vector{Int64}) with eltype Int64:
 -2  -2  -1  -1  -1  0  0  0  1  1  1
```
Because `fld(x, y)` implements strictly correct floored rounding based on the true value of floating-point numbers, unintuitive situations can arise. For example:
```julia-repl
julia> fld(6.0, 0.1)
59.0
julia> 6.0 / 0.1
60.0
julia> 6.0 / big(0.1)
59.99999999999999666933092612453056361837965690217069245739573412231113406246995
```


## [Mathematical Operators](#math-ops)
What is happening here is that the true value of the floating-point number written as `0.1` is slightly larger than the numerical value 1/10 while `6.0` represents the number 6 precisely. Therefore the true value of `6.0 / 0.1` is slightly less than 60. When doing division, this is rounded to precisely `60.0`, but `fld(6.0, 0.1)` always takes the floor of the true value, so the result is `59.0`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/div.jl#L109-L140)
```julia
cld(x, y)
```
Smallest integer larger than or equal to `x / y`. Equivalent to `div(x, y, RoundUp)`.
See also [`div`](#Base.div), [`fld`](#Base.fld).
**Examples**
```julia-repl
julia> cld(5.5, 2.2)
3.0

julia> cld.(-5:5, 3)'
1×11 adjoint(::Vector{Int64}) with eltype Int64:
 -1  -1  -1  0  0  0  1  1  1  2  2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/div.jl#L143-L159)
```julia
mod(x::Integer, r::AbstractUnitRange)
```
Find `y` in the range `r` such that $x ≡ y (mod n)$, where `n = length(r)`, i.e. `y = mod(x - first(r), n) + first(r)`.
See also [`mod1`](#Base.mod1).
**Examples**
```julia-repl
julia> mod(0, Base.OneTo(3))  # mod1(0, 3)
3

julia> mod(3, 0:2)  # mod(3, 3)
0
```
This method requires at least Julia 1.3.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L1475-L1494)
```julia
mod(x, y)
rem(x, y, RoundDown)
```


## [Mathematical Operators](#math-ops)
The reduction of `x` modulo `y`, or equivalently, the remainder of `x` after floored division by `y`, i.e. `x - y*fld(x,y)` if computed without intermediate rounding.
The result will have the same sign as `y`, and magnitude less than `abs(y)` (with some exceptions, see note below).
When used with floating point values, the exact result may not be representable by the type, and so rounding error may occur. In particular, if the exact result is very close to `y`, then it may be rounded to `y`.
See also: [`rem`](#Base.rem), [`div`](#Base.div), [`fld`](#Base.fld), [`mod1`](#Base.mod1), [`invmod`](#Base.invmod).
```julia-repl
julia> mod(8, 3)
2

julia> mod(9, 3)
0

julia> mod(8.9, 3)
2.9000000000000004

julia> mod(eps(), 3)
2.220446049250313e-16

julia> mod(-eps(), 3)
3.0

julia> mod.(-5:5, 3)'
1×11 adjoint(::Vector{Int64}) with eltype Int64:
 1  2  0  1  2  0  1  2  0  1  2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L246-L284)
```julia
rem(x::Integer, T::Type{<:Integer}) -> T
mod(x::Integer, T::Type{<:Integer}) -> T
%(x::Integer, T::Type{<:Integer}) -> T
```
Find `y::T` such that `x` ≡ `y` (mod n), where n is the number of integers representable in `T`, and `y` is an integer in `[typemin(T),typemax(T)]`. If `T` can represent any integer (e.g. `T == BigInt`), then this operation corresponds to a conversion to `T`.
**Examples**
```julia-repl
julia> x = 129 % Int8
-127

julia> typeof(x)
Int8

julia> x = 129 % BigInt
129

julia> typeof(x)
BigInt
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L595-L619)
```julia
rem(x, y)
%(x, y)
```
Remainder from Euclidean division, returning a value of the same sign as `x`, and smaller in magnitude than `y`. This value is always exact.
See also: [`div`](#Base.div), [`mod`](#Base.mod), [`mod1`](#Base.mod1), [`divrem`](#Base.divrem).
**Examples**
```julia-repl
julia> x = 15; y = 4;

julia> x % y
3

julia> x == div(x, y) * y + rem(x, y)
true

julia> rem.(-5:5, 3)'
1×11 adjoint(::Vector{Int64}) with eltype Int64:
 -2  -1  0  -2  -1  0  1  2  0  1  2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L758-L781)
```julia
rem(x, y, r::RoundingMode=RoundToZero)
```
Compute the remainder of `x` after integer division by `y`, with the quotient rounded according to the rounding mode `r`. In other words, the quantity
```julia
x - y * round(x / y, r)
```
without any intermediate rounding.
-   if `r == RoundNearest`, then the result is exact, and in the interval $\[-\|y\| / 2, \|y\| / 2\]$. See also [`RoundNearest`](#Base.Rounding.RoundNearest).
-   if `r == RoundToZero` (default), then the result is exact, and in the interval $\[0, \|y\|)$ if `x` is positive, or $(-\|y\|, 0\]$ otherwise. See also [`RoundToZero`](#Base.Rounding.RoundToZero).


## [Mathematical Operators](#math-ops)
-   if `r == RoundDown`, then the result is in the interval $\[0, y)$ if `y` is positive, or $(y, 0\]$ otherwise. The result may not be exact if `x` and `y` have different signs, and `abs(x) < abs(y)`. See also [`RoundDown`](#Base.Rounding.RoundDown).
-   if `r == RoundUp`, then the result is in the interval $(-y, 0\]$ if `y` is positive, or $\[0, -y)$ otherwise. The result may not be exact if `x` and `y` have the same sign, and `abs(x) < abs(y)`. See also [`RoundUp`](#Base.Rounding.RoundUp).
-   if `r == RoundFromZero`, then the result is in the interval $(-y, 0\]$ if `y` is positive, or $\[0, -y)$ otherwise. The result may not be exact if `x` and `y` have the same sign, and `abs(x) < abs(y)`. See also [`RoundFromZero`](#Base.Rounding.RoundFromZero).
`RoundFromZero` requires at least Julia 1.9.
**Examples:**
```julia-repl
julia> x = 9; y = 4;

julia> x % y  # same as rem(x, y)
1

julia> x ÷ y  # same as div(x, y)
2

julia> x == div(x, y) * y + rem(x, y)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/div.jl#L51-L95)
```julia
rem2pi(x, r::RoundingMode)
```
Compute the remainder of `x` after integer division by `2π`, with the quotient rounded according to the rounding mode `r`. In other words, the quantity
```julia
x - 2π*round(x/(2π),r)
```
without any intermediate rounding. This internally uses a high precision approximation of 2π, and so will give a more accurate result than `rem(x,2π,r)`


## [Mathematical Operators](#math-ops)
-   if `r == RoundNearest`, then the result is in the interval $\[-π, π\]$. This will generally be the most accurate result. See also [`RoundNearest`](#Base.Rounding.RoundNearest).
-   if `r == RoundToZero`, then the result is in the interval $\[0, 2π\]$ if `x` is positive,. or $\[-2π, 0\]$ otherwise. See also [`RoundToZero`](#Base.Rounding.RoundToZero).
-   if `r == RoundDown`, then the result is in the interval $\[0, 2π\]$. See also [`RoundDown`](#Base.Rounding.RoundDown).
-   if `r == RoundUp`, then the result is in the interval $\[-2π, 0\]$. See also [`RoundUp`](#Base.Rounding.RoundUp).
**Examples**
```julia-repl
julia> rem2pi(7pi/4, RoundNearest)
-0.7853981633974485

julia> rem2pi(7pi/4, RoundDown)
5.497787143782138
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L1263-L1293)
```julia
mod2pi(x)
```
Modulus after division by `2π`, returning in the range $\[0,2π)$.
This function computes a floating point representation of the modulus after division by numerically exact `2π`, and is therefore not exactly the same as `mod(x,2π)`, which would compute the modulus of `x` relative to division by the floating-point number `2π`.
Depending on the format of the input value, the closest representable value to 2π may be less than 2π. For example, the expression `mod2pi(2π)` will not return `0`, because the intermediate value of `2*π` is a `Float64` and `2*Float64(π) < 2*big(π)`. See [`rem2pi`](#Base.Math.rem2pi) for more refined control of this behavior.
**Examples**


## [Mathematical Operators](#math-ops)
```julia-repl
julia> mod2pi(9*pi/4)
0.7853981633974481
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L1425-L1445)
```julia
divrem(x, y, r::RoundingMode=RoundToZero)
```
The quotient and remainder from Euclidean division. Equivalent to `(div(x, y, r), rem(x, y, r))`. Equivalently, with the default value of `r`, this call is equivalent to `(x ÷ y, x % y)`.
See also: [`fldmod`](#Base.fldmod), [`cld`](#Base.cld).
**Examples**
```julia-repl
julia> divrem(3, 7)
(0, 3)

julia> divrem(7, 3)
(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/div.jl#L163-L180)
```julia
fldmod(x, y)
```
The floored quotient and modulus after division. A convenience wrapper for `divrem(x, y, RoundDown)`. Equivalent to `(fld(x, y), mod(x, y))`.
See also: [`fld`](#Base.fld), [`cld`](#Base.cld), [`fldmod1`](#Base.fldmod1).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/div.jl#L268-L275)
```julia
fld1(x, y)
```
Flooring division, returning a value consistent with `mod1(x,y)`
See also [`mod1`](#Base.mod1), [`fldmod1`](#Base.fldmod1).
**Examples**
```julia-repl
julia> x = 15; y = 4;

julia> fld1(x, y)
4

julia> x == fld(x, y) * y + mod(x, y)
true

julia> x == (fld1(x, y) - 1) * y + mod1(x, y)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L842-L862)
```julia
mod1(x, y)
```


## [Mathematical Operators](#math-ops)
Modulus after flooring division, returning a value `r` such that `mod(r, y) == mod(x, y)` in the range $(0, y\]$ for positive `y` and in the range $\[y,0)$ for negative `y`.
With integer arguments and positive `y`, this is equal to `mod(x, 1:y)`, and hence natural for 1-based indexing. By comparison, `mod(x, y) == mod(x, 0:y-1)` is natural for computations with offsets or strides.
See also [`mod`](#Base.mod), [`fld1`](#Base.fld1), [`fldmod1`](#Base.fldmod1).
**Examples**
```julia-repl
julia> mod1(4, 2)
2

julia> mod1.(-5:5, 3)'
1×11 adjoint(::Vector{Int64}) with eltype Int64:
 1  2  3  1  2  3  1  2  3  1  2

julia> mod1.([-0.1, 0, 0.1, 1, 2, 2.9, 3, 3.1]', 3)
1×8 Matrix{Float64}:
 2.9  3.0  0.1  1.0  2.0  2.9  3.0  0.1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L813-L838)
```julia
fldmod1(x, y)
```
Return `(fld1(x,y), mod1(x,y))`.
See also [`fld1`](#Base.fld1), [`mod1`](#Base.mod1).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L869-L875)
```julia
//(num, den)
```
Divide two integers or rational numbers, giving a [`Rational`](../numbers/#Base.Rational) result. More generally, `//` can be used for exact rational division of other numeric types with integer or rational components, such as complex numbers with integer components.


## [Mathematical Operators](#math-ops)
Note that floating-point ([`AbstractFloat`](../numbers/#Core.AbstractFloat)) arguments are not permitted by `//` (even if the values are rational). The arguments must be subtypes of [`Integer`](../numbers/#Core.Integer), `Rational`, or composites thereof.
**Examples**
```julia-repl
julia> 3 // 5
3//5

julia> (3 // 5) // (2 // 1)
3//10

julia> (1+2im) // (3+4im)
11//25 + 2//25*im

julia> 1.0 // 2
ERROR: MethodError: no method matching //(::Float64, ::Int64)
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rational.jl#L57-L83)
```julia
rationalize([T<:Integer=Int,] x; tol::Real=eps(x))
```
Approximate floating point number `x` as a [`Rational`](../numbers/#Base.Rational) number with components of the given integer type. The result will differ from `x` by no more than `tol`.
**Examples**
```julia-repl
julia> rationalize(5.6)
28//5

julia> a = rationalize(BigInt, 10.3)
103//10

julia> typeof(numerator(a))
BigInt
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rational.jl#L188-L205)
```julia
numerator(x)
```
Numerator of the rational representation of `x`.
**Examples**
```julia-repl
julia> numerator(2//3)
2

julia> numerator(4)
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rational.jl#L282-L295)
```julia
denominator(x)
```
Denominator of the rational representation of `x`.
**Examples**
```julia-repl
julia> denominator(2//3)
3

julia> denominator(4)
1
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rational.jl#L299-L312)
```julia
<<(x, n)
```
Left bit shift operator, `x << n`. For `n >= 0`, the result is `x` shifted left by `n` bits, filling with `0`s. This is equivalent to `x * 2^n`. For `n < 0`, this is equivalent to `x >> -n`.
**Examples**
```julia-repl
julia> Int8(3) << 2
12

julia> bitstring(Int8(3))
"00000011"

julia> bitstring(Int8(12))
"00001100"
```
See also [`>>`](#Base.:%3E%3E), [`>>>`](#Base.:%3E%3E%3E), [`exp2`](#Base.exp2), [`ldexp`](#Base.Math.ldexp).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L640-L659)
```julia
<<(B::BitVector, n) -> BitVector
```
Left bit shift operator, `B << n`. For `n >= 0`, the result is `B` with elements shifted `n` positions backwards, filling with `false` values. If `n < 0`, elements are shifted forwards. Equivalent to `B >> -n`.
**Examples**
```julia-repl
julia> B = BitVector([true, false, true, false, false])
5-element BitVector:
 1
 0
 1
 0
 0

julia> B << 1
5-element BitVector:
 0
 1
 0
 0
 0

julia> B << -1
5-element BitVector:
 0
 1
 0
 1
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L1378-L1412)
```julia
>>(x, n)
```


## [Mathematical Operators](#math-ops)
Right bit shift operator, `x >> n`. For `n >= 0`, the result is `x` shifted right by `n` bits, filling with `0`s if `x >= 0`, `1`s if `x < 0`, preserving the sign of `x`. This is equivalent to `fld(x, 2^n)`. For `n < 0`, this is equivalent to `x << -n`.
**Examples**
```julia-repl
julia> Int8(13) >> 2
3

julia> bitstring(Int8(13))
"00001101"

julia> bitstring(Int8(3))
"00000011"

julia> Int8(-14) >> 2
-4

julia> bitstring(Int8(-14))
"11110010"

julia> bitstring(Int8(-4))
"11111100"
```
See also [`>>>`](#Base.:%3E%3E%3E), [`<<`](#Base.:%3C%3C).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L675-L704)
```julia
>>(B::BitVector, n) -> BitVector
```
Right bit shift operator, `B >> n`. For `n >= 0`, the result is `B` with elements shifted `n` positions forward, filling with `false` values. If `n < 0`, elements are shifted backwards. Equivalent to `B << -n`.
**Examples**
```julia-repl
julia> B = BitVector([true, false, true, false, false])
5-element BitVector:
 1
 0
 1
 0
 0

julia> B >> 1
5-element BitVector:
 0
 1
 0
 1
 0

julia> B >> -1
5-element BitVector:
 0
 1
 0
 0
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L1340-L1374)
```julia
>>>(x, n)
```
Unsigned right bit shift operator, `x >>> n`. For `n >= 0`, the result is `x` shifted right by `n` bits, filling with `0`s. For `n < 0`, this is equivalent to `x << -n`.


## [Mathematical Operators](#math-ops)
For [`Unsigned`](../numbers/#Core.Unsigned) integer types, this is equivalent to [`>>`](#Base.:%3E%3E). For [`Signed`](../numbers/#Core.Signed) integer types, this is equivalent to `signed(unsigned(x) >> n)`.
**Examples**
```julia-repl
julia> Int8(-14) >>> 2
60

julia> bitstring(Int8(-14))
"11110010"

julia> bitstring(Int8(60))
"00111100"
```
[`BigInt`](../numbers/#Base.GMP.BigInt)s are treated as if having infinite size, so no filling is required and this is equivalent to [`>>`](#Base.:%3E%3E).
See also [`>>`](#Base.:%3E%3E), [`<<`](#Base.:%3C%3C).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L716-L742)
```julia
>>>(B::BitVector, n) -> BitVector
```
Unsigned right bitshift operator, `B >>> n`. Equivalent to `B >> n`. See [`>>`](#Base.:%3E%3E) for details and examples.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitarray.jl#L1415-L1420)
```julia
bitrotate(x::Base.BitInteger, k::Integer)
```
`bitrotate(x, k)` implements bitwise rotation. It returns the value of `x` with its bits rotated left `k` times. A negative value of `k` will rotate to the right instead.
This function requires Julia 1.5 or later.
See also: [`<<`](#Base.:%3C%3C), [`circshift`](../arrays/#Base.circshift), [`BitArray`](../arrays/#Base.BitArray).


## [Mathematical Operators](#math-ops)
```julia-repl
julia> bitrotate(UInt8(114), 2)
0xc9

julia> bitstring(bitrotate(0b01110010, 2))
"11001001"

julia> bitstring(bitrotate(0b01110010, -2))
"10011100"

julia> bitstring(bitrotate(0b01110010, 8))
"01110010"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L561-L586)
```julia
:expr
```
Quote an expression `expr`, returning the abstract syntax tree (AST) of `expr`. The AST may be of type `Expr`, `Symbol`, or a literal value. The syntax `:identifier` evaluates to a `Symbol`.
See also: [`Expr`](../base/#Core.Expr), [`Symbol`](../base/#Core.Symbol), [`Meta.parse`](../base/#Base.Meta.parse-Tuple%7BAbstractString,%20Int64%7D)
**Examples**
```julia-repl
julia> expr = :(a = b + 2*x)
:(a = b + 2x)

julia> sym = :some_identifier
:some_identifier

julia> value = :0xff
0xff

julia> typeof((expr, sym, value))
Tuple{Expr, Symbol, UInt8}
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L732-L755)
```julia
range(start, stop, length)
range(start, stop; length, step)
range(start; length, stop, step)
range(;start, length, stop, step)
```
Construct a specialized array with evenly spaced elements and optimized storage (an [`AbstractRange`](../collections/#Base.AbstractRange)) from the arguments. Mathematically a range is uniquely determined by any three of `start`, `step`, `stop` and `length`. Valid invocations of range are:
-   Call `range` with any three of `start`, `step`, `stop`, `length`.


## [Mathematical Operators](#math-ops)
-   Call `range` with two of `start`, `stop`, `length`. In this case `step` will be assumed to be one. If both arguments are Integers, a [`UnitRange`](../collections/#Base.UnitRange) will be returned.
-   Call `range` with one of `stop` or `length`. `start` and `step` will be assumed to be one.
See Extended Help for additional details on the returned type. See also [`logrange`](#Base.logrange) for logarithmically spaced points.
**Examples**
```julia-repl
julia> range(1, length=100)
1:100

julia> range(1, stop=100)
1:100

julia> range(1, step=5, length=100)
1:5:496

julia> range(1, step=5, stop=100)
1:5:96

julia> range(1, 10, length=101)
1.0:0.09:10.0

julia> range(1, 100, step=5)
1:5:96

julia> range(stop=10, length=5)
6:10

julia> range(stop=10, step=1, length=5)
6:1:10

julia> range(start=1, step=1, stop=10)
1:1:10

julia> range(; length = 10)
Base.OneTo(10)

julia> range(; stop = 6)
Base.OneTo(6)

julia> range(; stop = 6.5)
1.0:1.0:6.0
```
If `length` is not specified and `stop - start` is not an integer multiple of `step`, a range that ends before `stop` will be produced.
```julia-repl
julia> range(1, 3.5, step=2)
1.0:2.0:3.0
```
Special care is taken to ensure intermediate values are computed rationally. To avoid this induced overhead, see the [`LinRange`](../collections/#Base.LinRange) constructor.
`stop` as a positional argument requires at least Julia 1.1.
The versions without keyword arguments and `start` as a keyword argument require at least Julia 1.7.


## [Mathematical Operators](#math-ops)
The versions with `stop` as a sole keyword argument, or `length` as a sole keyword argument require at least Julia 1.8.
**Extended Help**
`range` will produce a `Base.OneTo` when the arguments are Integers and
-   Only `length` is provided
-   Only `stop` is provided
`range` will produce a `UnitRange` when the arguments are Integers and
-   Only `start` and `stop` are provided
-   Only `length` and `stop` are provided
A `UnitRange` is not produced if `step` is provided even if specified as one.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L58-L145)
```julia
Base.OneTo(n)
```
Define an `AbstractUnitRange` that behaves like `1:n`, with the added distinction that the lower limit is guaranteed (by the type system) to be 1.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L447-L453)
```julia
StepRangeLen(         ref::R, step::S, len, [offset=1]) where {  R,S}
StepRangeLen{T,R,S}(  ref::R, step::S, len, [offset=1]) where {T,R,S}
StepRangeLen{T,R,S,L}(ref::R, step::S, len, [offset=1]) where {T,R,S,L}
```


## [Mathematical Operators](#math-ops)
A range `r` where `r[i]` produces values of type `T` (in the first form, `T` is deduced automatically), parameterized by a `ref`erence value, a `step`, and the `len`gth. By default `ref` is the starting value `r[1]`, but alternatively you can supply it as the value of `r[offset]` for some other index `1 <= offset <= len`. The syntax `a:b` or `a:b:c`, where any of `a`, `b`, or `c` are floating-point numbers, creates a `StepRangeLen`.
The 4th type parameter `L` requires at least Julia 1.7.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L480-L495)
```julia
logrange(start, stop, length)
logrange(start, stop; length)
```
Construct a specialized array whose elements are spaced logarithmically between the given endpoints. That is, the ratio of successive elements is a constant, calculated from the length.
This is similar to `geomspace` in Python. Unlike `PowerRange` in Mathematica, you specify the number of elements not the ratio. Unlike `logspace` in Python and Matlab, the `start` and `stop` arguments are always the first and last elements of the result, not powers applied to some base.
**Examples**


## [Mathematical Operators](#math-ops)
```julia-repl
julia> logrange(10, 4000, length=3)
3-element Base.LogRange{Float64, Base.TwicePrecision{Float64}}:
 10.0, 200.0, 4000.0

julia> ans[2] ≈ sqrt(10 * 4000)  # middle element is the geometric mean
true

julia> range(10, 40, length=3)[2] ≈ (10 + 40)/2  # arithmetic mean
true

julia> logrange(1f0, 32f0, 11)
11-element Base.LogRange{Float32, Float64}:
 1.0, 1.41421, 2.0, 2.82843, 4.0, 5.65685, 8.0, 11.3137, 16.0, 22.6274, 32.0

julia> logrange(1, 1000, length=4) ≈ 10 .^ (0:3)
true
```
See the [`LogRange`](#Base.LogRange) type for further details.
See also [`range`](#Base.range) for linearly spaced points.
This function requires at least Julia 1.11.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L1499-L1538)
```julia
LogRange{T}(start, stop, len) <: AbstractVector{T}
```
A range whose elements are spaced logarithmically between `start` and `stop`, with spacing controlled by `len`. Returned by [`logrange`](#Base.logrange).
Like [`LinRange`](../collections/#Base.LinRange), the first and last elements will be exactly those provided, but intermediate values may have small floating-point errors. These are calculated using the logs of the endpoints, which are stored on construction, often in higher precision than `T`.
**Examples**


## [Mathematical Operators](#math-ops)
```julia-repl
julia> logrange(1, 4, length=5)
5-element Base.LogRange{Float64, Base.TwicePrecision{Float64}}:
 1.0, 1.41421, 2.0, 2.82843, 4.0

julia> Base.LogRange{Float16}(1, 4, 5)
5-element Base.LogRange{Float16, Float64}:
 1.0, 1.414, 2.0, 2.828, 4.0

julia> logrange(1e-310, 1e-300, 11)[1:2:end]
6-element Vector{Float64}:
 1.0e-310
 9.999999999999974e-309
 9.999999999999981e-307
 9.999999999999988e-305
 9.999999999999994e-303
 1.0e-300

julia> prevfloat(1e-308, 5) == ans[2]
true
```
Note that integer eltype `T` is not allowed. Use for instance `round.(Int, xs)`, or explicit powers of some integer base:
```julia-repl
julia> xs = logrange(1, 512, 4)
4-element Base.LogRange{Float64, Base.TwicePrecision{Float64}}:
 1.0, 8.0, 64.0, 512.0

julia> 2 .^ (0:3:9) |> println
[1, 8, 64, 512]
```
This type requires at least Julia 1.11.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L1543-L1591)
```julia
==(x, y)
```


## [Mathematical Operators](#math-ops)
Generic equality operator. Falls back to [`===`](../base/#Core.:===). Should be implemented for all types with a notion of equality, based on the abstract value that an instance represents. For example, all numeric types are compared by numeric value, ignoring type. Strings are compared as sequences of characters, ignoring encoding. Collections of the same type generally compare their key sets, and if those are `==`, then compare the values for each of those keys, returning true if all such pairs are `==`. Other properties are typically not taken into account (such as the exact type).
This operator follows IEEE semantics for floating-point numbers: `0.0 == -0.0` and `NaN != NaN`.
The result is of type `Bool`, except when one of the operands is [`missing`](../../manual/missing/#missing), in which case `missing` is returned ([three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic)). Collections generally implement three-valued logic akin to [`all`](../collections/#Base.all-Tuple%7BAny%7D), returning missing if any operands contain missing values and all other pairs are equal. Use [`isequal`](../base/#Base.isequal) or [`===`](../base/#Core.:===) to always get a `Bool` result.
**Implementation**
New numeric types should implement this function for two arguments of the new type, and handle comparison to other types via promotion rules where possible.


## [Mathematical Operators](#math-ops)
[`isequal`](../base/#Base.isequal) falls back to `==`, so new methods of `==` will be used by the [`Dict`](../collections/#Base.Dict) type to compare keys. If your type will be used as a dictionary key, it should therefore also implement [`hash`](../base/#Base.hash).
If some type defines `==`, [`isequal`](../base/#Base.isequal), and [`isless`](../base/#Base.isless) then it should also implement [`<`](#Base.:%3C) to ensure consistency of comparisons.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L48-L79)
```julia
!=(x, y)
≠(x,y)
```
Not-equals comparison operator. Always gives the opposite answer as [`==`](#Base.:==).
**Implementation**
New types should generally not implement this, and rely on the fallback definition `!=(x,y) = !(x==y)` instead.
**Examples**
```julia-repl
julia> 3 != 2
true

julia> "foo" ≠ "foo"
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L258-L276)
```julia
!=(x)
```
Create a function that compares its argument to `x` using [`!=`](#Base.:!=), i.e. a function equivalent to `y -> y != x`. The returned function is of type `Base.Fix2{typeof(!=)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.2.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L1168-L1178)
```julia
!==(x, y)
≢(x,y)
```
Always gives the opposite answer as [`===`](../base/#Core.:===).
**Examples**


## [Mathematical Operators](#math-ops)
```julia-repl
julia> a = [1, 2]; b = [1, 2];

julia> a ≢ b
true

julia> a ≢ a
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L307-L323)
```julia
<(x, y)
```
Less-than comparison operator. Falls back to [`isless`](../base/#Base.isless). Because of the behavior of floating-point NaN values, this operator implements a partial order.
**Implementation**
New types with a canonical partial order should implement this function for two arguments of the new type. Types with a canonical total order should implement [`isless`](../base/#Base.isless) instead.
See also [`isunordered`](../base/#Base.isunordered).
**Examples**
```julia-repl
julia> 'a' < 'b'
true

julia> "abc" < "abd"
true

julia> 5 < 3
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L327-L352)
```julia
<(x)
```
Create a function that compares its argument to `x` using [`<`](#Base.:%3C), i.e. a function equivalent to `y -> y < x`. The returned function is of type `Base.Fix2{typeof(<)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.2.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L1220-L1230)
```julia
<=(x, y)
≤(x,y)
```
Less-than-or-equals comparison operator. Falls back to `(x < y) | (x == y)`.
**Examples**
```julia-repl
julia> 'a' <= 'b'
true

julia> 7 ≤ 7 ≤ 9
true

julia> "abc" ≤ "abc"
true

julia> 5 <= 3
false
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L381-L401)
```julia
<=(x)
```
Create a function that compares its argument to `x` using [`<=`](#Base.:%3C=), i.e. a function equivalent to `y -> y <= x`. The returned function is of type `Base.Fix2{typeof(<=)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.2.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L1194-L1204)
```julia
>(x, y)
```
Greater-than comparison operator. Falls back to `y < x`.
**Implementation**
Generally, new types should implement [`<`](#Base.:%3C) instead of this function, and rely on the fallback definition `>(x, y) = y < x`.
**Examples**
```julia-repl
julia> 'a' > 'b'
false

julia> 7 > 3 > 1
true

julia> "abc" > "abd"
false

julia> 5 > 3
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L355-L378)
```julia
>(x)
```
Create a function that compares its argument to `x` using [`>`](#Base.:%3E), i.e. a function equivalent to `y -> y > x`. The returned function is of type `Base.Fix2{typeof(>)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.2.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L1207-L1217)
```julia
>=(x, y)
≥(x,y)
```
Greater-than-or-equals comparison operator. Falls back to `y <= x`.
**Examples**


## [Mathematical Operators](#math-ops)
```julia-repl
julia> 'a' >= 'b'
false

julia> 7 ≥ 7 ≥ 3
true

julia> "abc" ≥ "abc"
true

julia> 5 >= 3
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L405-L425)
```julia
>=(x)
```
Create a function that compares its argument to `x` using [`>=`](#Base.:%3E=), i.e. a function equivalent to `y -> y >= x`. The returned function is of type `Base.Fix2{typeof(>=)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.2.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L1181-L1191)
```julia
cmp(x,y)
```
Return -1, 0, or 1 depending on whether `x` is less than, equal to, or greater than `y`, respectively. Uses the total order implemented by `isless`.
**Examples**
```julia-repl
julia> cmp(1, 2)
-1

julia> cmp(2, 1)
1

julia> cmp(2+im, 3-im)
ERROR: MethodError: no method matching isless(::Complex{Int64}, ::Complex{Int64})
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L433-L451)
```julia
cmp(<, x, y)
```
Return -1, 0, or 1 depending on whether `x` is less than, equal to, or greater than `y`, respectively. The first argument specifies a less-than comparison function to use.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L454-L459)
```julia
cmp(a::AbstractString, b::AbstractString) -> Int
```


## [Mathematical Operators](#math-ops)
Compare two strings. Return `0` if both strings have the same length and the character at each index is the same in both strings. Return `-1` if `a` is a prefix of `b`, or if `a` comes before `b` in alphabetical order. Return `1` if `b` is a prefix of `a`, or if `b` comes before `a` in alphabetical order (technically, lexicographical order by Unicode code points).
**Examples**
```julia-repl
julia> cmp("abc", "abc")
0

julia> cmp("ab", "abc")
-1

julia> cmp("abc", "ab")
1

julia> cmp("ab", "ac")
-1

julia> cmp("ac", "ab")
1

julia> cmp("α", "a")
1

julia> cmp("b", "β")
-1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L279-L311)
```julia
~(x)
```
Bitwise not.
See also: [`!`](#Base.:!), [`&`](#Base.:&), [`|`](#Base.:%7C).
**Examples**
```julia-repl
julia> ~4
-5

julia> ~10
-11

julia> ~true
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L302-L320)
```julia
x & y
```
Bitwise and. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](../../manual/missing/#missing) if one operand is `missing` and the other is `true`. Add parentheses for function application form: `(&)(x, y)`.
See also: [`|`](#Base.:%7C), [`xor`](#Base.xor), [`&&`](#&&).
**Examples**
```julia-repl
julia> 4 & 10
0

julia> 4 & 12
4

julia> true & missing
missing

julia> false & missing
false
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L323-L346)
```julia
x | y
```
Bitwise or. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](../../manual/missing/#missing) if one operand is `missing` and the other is `false`.
See also: [`&`](#Base.:&), [`xor`](#Base.xor), [`||`](#%7C%7C).
**Examples**
```julia-repl
julia> 4 | 10
14

julia> 4 | 1
5

julia> true | missing
true

julia> false | missing
missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L349-L371)
```julia
xor(x, y)
⊻(x, y)
```
Bitwise exclusive or of `x` and `y`. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](../../manual/missing/#missing) if one of the arguments is `missing`.
The infix operation `a ⊻ b` is a synonym for `xor(a,b)`, and `⊻` can be typed by tab-completing `\xor` or `\veebar` in the Julia REPL.
**Examples**
```julia-repl
julia> xor(true, false)
true

julia> xor(true, true)
false

julia> xor(true, missing)
missing

julia> false ⊻ false
false

julia> [true; true; false] .⊻ [true; false; false]
3-element BitVector:
 0
 1
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bool.jl#L41-L72)
```julia
nand(x, y)
⊼(x, y)
```


## [Mathematical Operators](#math-ops)
Bitwise nand (not and) of `x` and `y`. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](../../manual/missing/#missing) if one of the arguments is `missing`.
The infix operation `a ⊼ b` is a synonym for `nand(a,b)`, and `⊼` can be typed by tab-completing `\nand` or `\barwedge` in the Julia REPL.
**Examples**
```julia-repl
julia> nand(true, false)
true

julia> nand(true, true)
false

julia> nand(true, missing)
missing

julia> false ⊼ false
true

julia> [true; true; false] .⊼ [true; false; false]
3-element BitVector:
 0
 1
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bool.jl#L75-L106)
```julia
nor(x, y)
⊽(x, y)
```
Bitwise nor (not or) of `x` and `y`. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](../../manual/missing/#missing) if one of the arguments is `missing` and the other is not `true`.
The infix operation `a ⊽ b` is a synonym for `nor(a,b)`, and `⊽` can be typed by tab-completing `\nor` or `\barvee` in the Julia REPL.
**Examples**
```julia-repl
julia> nor(true, false)
false

julia> nor(true, true)
false

julia> nor(true, missing)
false

julia> false ⊽ false
true

julia> false ⊽ missing
missing

julia> [true; true; false] .⊽ [true; false; false]
3-element BitVector:
 0
 0
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bool.jl#L109-L144)
```julia
!(x)
```


## [Mathematical Operators](#math-ops)
Boolean not. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](../../manual/missing/#missing) if `x` is `missing`.
See also [`~`](#Base.:~) for bitwise not.
**Examples**
```julia-repl
julia> !true
false

julia> !false
true

julia> !missing
missing

julia> .![true false true]
1×3 BitMatrix:
 0  1  0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bool.jl#L11-L34)
```julia
!f::Function
```
Predicate function negation: when the argument of `!` is a function, it returns a composed function which computes the boolean negation of `f`.
See also [`∘`](../base/#Base.:∘).
**Examples**
```julia-repl
julia> str = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"
"∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"

julia> filter(isletter, str)
"εδxyδfxfyε"

julia> filter(!isletter, str)
"∀  > 0, ∃  > 0: |-| <  ⇒ |()-()| < "
```
Starting with Julia 1.9, `!f` returns a [`ComposedFunction`](../base/#Base.ComposedFunction) instead of an anonymous function.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L1085-L1106)
```julia
x && y
```
Short-circuiting boolean AND.
See also [`&`](#Base.:&), the ternary operator `? :`, and the manual section on [control flow](../../manual/control-flow/#man-conditional-evaluation).
**Examples**
```julia-repl
julia> x = 3;

julia> x > 1 && x < 10 && x isa Int
true

julia> x < 0 && error("expected positive x")
false
```


## [Mathematical Operators](#math-ops)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L1266-L1283)
```julia
x || y
```
Short-circuiting boolean OR.
See also: [`|`](#Base.:%7C), [`xor`](#Base.xor), [`&&`](#&&).
**Examples**
```julia-repl
julia> pi < 3 || ℯ < 3
true

julia> false || true || println("neither is true!")
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L1286-L1301)


## [Mathematical Functions](#Mathematical-Functions)
```julia
isapprox(x, y; atol::Real=0, rtol::Real=atol>0 ? 0 : √eps, nans::Bool=false[, norm::Function])
```
Inexact equality comparison. Two numbers compare equal if their relative distance *or* their absolute distance is within tolerance bounds: `isapprox` returns `true` if `norm(x-y) <= max(atol, rtol*max(norm(x), norm(y)))`. The default `atol` (absolute tolerance) is zero and the default `rtol` (relative tolerance) depends on the types of `x` and `y`. The keyword argument `nans` determines whether or not NaN values are considered equal (defaults to false).
For real or complex floating-point values, if an `atol > 0` is not specified, `rtol` defaults to the square root of [`eps`](../base/#Base.eps-Tuple%7BType%7B%3C:AbstractFloat%7D%7D) of the type of `x` or `y`, whichever is bigger (least precise). This corresponds to requiring equality of about half of the significant digits. Otherwise, e.g. for integer arguments or if an `atol > 0` is supplied, `rtol` defaults to zero.
The `norm` keyword defaults to `abs` for numeric `(x,y)` and to `LinearAlgebra.norm` for arrays (where an alternative `norm` choice is sometimes useful). When `x` and `y` are arrays, if `norm(x-y)` is not finite (i.e. `±Inf` or `NaN`), the comparison falls back to checking whether all elements of `x` and `y` are approximately equal component-wise.
The binary operator `≈` is equivalent to `isapprox` with the default arguments, and `x ≉ y` is equivalent to `!isapprox(x,y)`.


## [Mathematical Functions](#Mathematical-Functions)
Note that `x ≈ 0` (i.e., comparing to zero with the default tolerances) is equivalent to `x == 0` since the default `atol` is `0`. In such cases, you should either supply an appropriate `atol` (or use `norm(x) ≤ atol`) or rearrange your code (e.g. use `x ≈ y` rather than `x - y ≈ 0`). It is not possible to pick a nonzero `atol` automatically because it depends on the overall scaling (the "units") of your problem: for example, in `x - y ≈ 0`, `atol=1e-9` is an absurdly small tolerance if `x` is the [radius of the Earth](https://en.wikipedia.org/wiki/Earth_radius) in meters, but an absurdly large tolerance if `x` is the [radius of a Hydrogen atom](https://en.wikipedia.org/wiki/Bohr_radius) in meters.
Passing the `norm` keyword argument when comparing numeric (non-array) arguments requires Julia 1.6 or later.
**Examples**
```julia-repl
julia> isapprox(0.1, 0.15; atol=0.05)
true

julia> isapprox(0.1, 0.15; rtol=0.34)
true

julia> isapprox(0.1, 0.15; rtol=0.33)
false

julia> 0.1 + 1e-10 ≈ 0.1
true

julia> 1e-10 ≈ 0
false

julia> isapprox(1e-10, 0, atol=1e-8)
true

julia> isapprox([10.0^9, 1.0], [10.0^9, 2.0]) # using `norm`
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/floatfuncs.jl#L159-L219)
```julia
isapprox(x; kwargs...) / ≈(x; kwargs...)
```
Create a function that compares its argument to `x` using `≈`, i.e. a function equivalent to `y -> y ≈ x`.
The keyword arguments supported here are the same as those in the 2-argument `isapprox`.


## [Mathematical Functions](#Mathematical-Functions)
This method requires Julia 1.5 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/floatfuncs.jl#L241-L250)
```julia
sin(x)
```
Compute sine of `x`, where `x` is in radians.
See also [`sind`](#Base.Math.sind), [`sinpi`](#Base.Math.sinpi), [`sincos`](#Base.Math.sincos-Tuple%7BFloat64%7D), [`cis`](#Base.cis), [`asin`](#Base.asin-Tuple%7BNumber%7D).
**Examples**
```julia-repl
julia> round.(sin.(range(0, 2pi, length=9)'), digits=3)
1×9 Matrix{Float64}:
 0.0  0.707  1.0  0.707  0.0  -0.707  -1.0  -0.707  -0.0

julia> sind(45)
0.7071067811865476

julia> sinpi(1/4)
0.7071067811865475

julia> round.(sincos(pi/6), digits=3)
(0.5, 0.866)

julia> round(cis(pi/6), digits=3)
0.866 + 0.5im

julia> round(exp(im*pi/6), digits=3)
0.866 + 0.5im
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L403-L431)
```julia
cos(x)
```
Compute cosine of `x`, where `x` is in radians.
See also [`cosd`](#Base.Math.cosd), [`cospi`](#Base.Math.cospi), [`sincos`](#Base.Math.sincos-Tuple%7BFloat64%7D), [`cis`](#Base.cis).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L434-L440)
```julia
sincos(x)
```
Simultaneously compute the sine and cosine of `x`, where `x` is in radians, returning a tuple `(sine, cosine)`.
See also [`cis`](#Base.cis), [`sincospi`](#Base.Math.sincospi), [`sincosd`](#Base.Math.sincosd).


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L167-L174)
```julia
tan(x)
```
Compute tangent of `x`, where `x` is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L443-L447)
```julia
sind(x)
```
Compute sine of `x`, where `x` is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1260-L1268)
```julia
cosd(x)
```
Compute cosine of `x`, where `x` is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1260-L1268)
```julia
tand(x)
```
Compute tangent of `x`, where `x` is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1260-L1268)
```julia
sincosd(x)
```
Simultaneously compute the sine and cosine of `x`, where `x` is in degrees.
This function requires at least Julia 1.3.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1242-L1249)
```julia
sinpi(x)
```


## [Mathematical Functions](#Mathematical-Functions)
Compute $\\sin(\\pi x)$ more accurately than `sin(pi*x)`, especially for large `x`.
See also [`sind`](#Base.Math.sind), [`cospi`](#Base.Math.cospi), [`sincospi`](#Base.Math.sincospi).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L785-L791)
```julia
cospi(x)
```
Compute $\\cos(\\pi x)$ more accurately than `cos(pi*x)`, especially for large `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L816-L820)
```julia
tanpi(x)
```
Compute $\\tan(\\pi x)$ more accurately than `tan(pi*x)`, especially for large `x`.
This function requires at least Julia 1.10.
See also [`tand`](#Base.Math.tand), [`sinpi`](#Base.Math.sinpi), [`cospi`](#Base.Math.cospi), [`sincospi`](#Base.Math.sincospi).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L882-L891)
```julia
sincospi(x)
```
Simultaneously compute [`sinpi(x)`](#Base.Math.sinpi) and [`cospi(x)`](#Base.Math.cospi) (the sine and cosine of `π*x`, where `x` is in radians), returning a tuple `(sine, cosine)`.
This function requires Julia 1.6 or later.
See also: [`cispi`](#Base.cispi), [`sincosd`](#Base.Math.sincosd), [`sinpi`](#Base.Math.sinpi).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L844-L854)
```julia
sinh(x)
```
Compute hyperbolic sine of `x`.


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L315-L319)
```julia
cosh(x)
```
Compute hyperbolic cosine of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L322-L326)
```julia
tanh(x)
```
Compute hyperbolic tangent of `x`.
See also [`tan`](#Base.tan-Tuple%7BNumber%7D), [`atanh`](#Base.atanh-Tuple%7BNumber%7D).
**Examples**
```julia-repl
julia> tanh.(-3:3f0)  # Here 3f0 isa Float32
7-element Vector{Float32}:
 -0.9950548
 -0.9640276
 -0.7615942
  0.0
  0.7615942
  0.9640276
  0.9950548

julia> tan.(im .* (1:3))
3-element Vector{ComplexF64}:
 0.0 + 0.7615941559557649im
 0.0 + 0.9640275800758169im
 0.0 + 0.9950547536867306im
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L329-L355)
```julia
asin(x)
```
Compute the inverse sine of `x`, where the output is in radians.
See also [`asind`](#Base.Math.asind) for output in degrees.
**Examples**
```julia-repl
julia> asin.((0, 1/2, 1))
(0.0, 0.5235987755982989, 1.5707963267948966)

julia> asind.((0, 1/2, 1))
(0.0, 30.000000000000004, 90.0)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L450-L465)
```julia
acos(x)
```
Compute the inverse cosine of `x`, where the output is in radians
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L468-L472)
```julia
atan(y)
atan(y, x)
```


## [Mathematical Functions](#Mathematical-Functions)
Compute the inverse tangent of `y` or `y/x`, respectively.
For one real argument, this is the angle in radians between the positive *x*-axis and the point (1, *y*), returning a value in the interval $\[-\\pi/2, \\pi/2\]$.
For two arguments, this is the angle in radians between the positive *x*-axis and the point (*x*, *y*), returning a value in the interval $\[-\\pi, \\pi\]$. This corresponds to a standard [`atan2`](https://en.wikipedia.org/wiki/Atan2) function. Note that by convention `atan(0.0,x)` is defined as $\\pi$ and `atan(-0.0,x)` is defined as $-\\pi$ when `x < 0`.
See also [`atand`](#Base.Math.atand) for degrees.
**Examples**
```julia-repl
julia> rad2deg(atan(-1/√3))
-30.000000000000004

julia> rad2deg(atan(-1, √3))
-30.000000000000004

julia> rad2deg(atan(1, -√3))
150.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L358-L386)
```julia
asind(x)
```
Compute the inverse sine of `x`, where the output is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1279-L1287)
```julia
acosd(x)
```
Compute the inverse cosine of `x`, where the output is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1279-L1287)


## [Mathematical Functions](#Mathematical-Functions)
```julia
atand(y)
atand(y,x)
```
Compute the inverse tangent of `y` or `y/x`, respectively, where the output is in degrees.
The one-argument method supports square matrix arguments as of Julia 1.7.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1292-L1300)
```julia
sec(x)
```
Compute the secant of `x`, where `x` is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1131-L1135)
```julia
csc(x)
```
Compute the cosecant of `x`, where `x` is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1131-L1135)
```julia
cot(x)
```
Compute the cotangent of `x`, where `x` is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1131-L1135)
```julia
secd(x)
```
Compute the secant of `x`, where `x` is in degrees.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1141-L1145)
```julia
cscd(x)
```
Compute the cosecant of `x`, where `x` is in degrees.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1141-L1145)
```julia
cotd(x)
```
Compute the cotangent of `x`, where `x` is in degrees.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1141-L1145)
```julia
asec(x)
```


## [Mathematical Functions](#Mathematical-Functions)
Compute the inverse secant of `x`, where the output is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1155-L1157)
```julia
acsc(x)
```
Compute the inverse cosecant of `x`, where the output is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1155-L1157)
```julia
acot(x)
```
Compute the inverse cotangent of `x`, where the output is in radians.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1155-L1157)
```julia
asecd(x)
```
Compute the inverse secant of `x`, where the output is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1279-L1287)
```julia
acscd(x)
```
Compute the inverse cosecant of `x`, where the output is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1279-L1287)
```julia
acotd(x)
```
Compute the inverse cotangent of `x`, where the output is in degrees. If `x` is a matrix, `x` needs to be a square matrix.
Matrix arguments require Julia 1.7 or later.


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1279-L1287)
```julia
sech(x)
```
Compute the hyperbolic secant of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1136-L1140)
```julia
csch(x)
```
Compute the hyperbolic cosecant of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1136-L1140)
```julia
coth(x)
```
Compute the hyperbolic cotangent of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1136-L1140)
```julia
asinh(x)
```
Compute the inverse hyperbolic sine of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L389-L393)
```julia
acosh(x)
```
Compute the inverse hyperbolic cosine of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L475-L479)
```julia
atanh(x)
```
Compute the inverse hyperbolic tangent of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L482-L486)
```julia
asech(x)
```
Compute the inverse hyperbolic secant of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1158-L1160)
```julia
acsch(x)
```
Compute the inverse hyperbolic cosecant of `x`.


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1158-L1160)
```julia
acoth(x)
```
Compute the inverse hyperbolic cotangent of `x`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1158-L1160)
```julia
sinc(x)
```
Compute normalized sinc function $\\operatorname{sinc}(x) = \\sin(\\pi x) / (\\pi x)$ if $x \\neq 0$, and $1$ if $x = 0$.
See also [`cosc`](#Base.Math.cosc), its derivative.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1065-L1071)
```julia
cosc(x)
```
Compute $\\cos(\\pi x) / x - \\sin(\\pi x) / (\\pi x^2)$ if $x \\neq 0$, and $0$ if $x = 0$. This is the derivative of `sinc(x)`.
See also [`sinc`](#Base.Math.sinc).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/trig.jl#L1082-L1089)
```julia
deg2rad(x)
```
Convert `x` from degrees to radians.
See also [`rad2deg`](#Base.Math.rad2deg), [`sind`](#Base.Math.sind), [`pi`](../numbers/#Base.MathConstants.pi).
**Examples**
```julia-repl
julia> deg2rad(90)
1.5707963267948966
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L246-L258)
```julia
rad2deg(x)
```
Convert `x` from radians to degrees.
See also [`deg2rad`](#Base.Math.deg2rad).
**Examples**
```julia-repl
julia> rad2deg(pi)
180.0
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L231-L243)
```julia
hypot(x, y)
```
Compute the hypotenuse $\\sqrt{\|x\|^2+\|y\|^2}$ avoiding overflow and underflow.
This code is an implementation of the algorithm described in: An Improved Algorithm for `hypot(a,b)` by Carlos F. Borges The article is available online at arXiv at the link https://arxiv.org/abs/1904.09481
```julia
hypot(x...)
```
Compute the hypotenuse $\\sqrt{\\sum \|x_i\|^2}$ avoiding overflow and underflow.
See also `norm` in the [`LinearAlgebra`](../../stdlib/LinearAlgebra/#man-linalg) standard library.
**Examples**
```julia-repl
julia> a = Int64(10)^10;

julia> hypot(a, a)
1.4142135623730951e10

julia> √(a^2 + a^2) # a^2 overflows
ERROR: DomainError with -2.914184810805068e18:
sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
[...]

julia> hypot(3, 4im)
5.0

julia> hypot(-5.7)
5.7

julia> hypot(3, 4im, 12.0)
13.0

julia> using LinearAlgebra

julia> norm([a, a, a, a]) == hypot(a, a, a, a)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L660-L704)
```julia
log(x)
```
Compute the natural logarithm of `x`.


## [Mathematical Functions](#Mathematical-Functions)
Throws [`DomainError`](../base/#Core.DomainError) for negative [`Real`](../numbers/#Core.Real) arguments. Use complex arguments to obtain complex results. Has a branch cut along the negative real axis, for which `-0.0im` is taken to be below the axis.
See also [`ℯ`](../numbers/#Base.MathConstants.ℯ), [`log1p`](#Base.log1p), [`log2`](#Base.log2), [`log10`](#Base.log10).
**Examples**
```julia-repl
julia> log(2)
0.6931471805599453

julia> log(-3)
ERROR: DomainError with -3.0:
log was called with a negative real argument but will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]

julia> log(-3 + 0im)
1.0986122886681098 + 3.141592653589793im

julia> log(-3 - 0.0im)
1.0986122886681098 - 3.141592653589793im

julia> log.(exp.(-1:1))
3-element Vector{Float64}:
 -1.0
  0.0
  1.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L489-L524)
```julia
log(b,x)
```
Compute the base `b` logarithm of `x`. Throws [`DomainError`](../base/#Core.DomainError) for negative [`Real`](../numbers/#Core.Real) arguments.
**Examples**


## [Mathematical Functions](#Mathematical-Functions)
```julia-repl
julia> log(4,8)
1.5

julia> log(4,2)
0.5

julia> log(-2, 3)
ERROR: DomainError with -2.0:
log was called with a negative real argument but will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]

julia> log(2, -3)
ERROR: DomainError with -3.0:
log was called with a negative real argument but will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]
```
If `b` is a power of 2 or 10, [`log2`](#Base.log2) or [`log10`](#Base.log10) should be used, as these will typically be faster and more accurate. For example,
```julia-repl
julia> log(100,1000000)
2.9999999999999996

julia> log10(1000000)/2
3.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L267-L307)
```julia
log2(x)
```
Compute the logarithm of `x` to base 2. Throws [`DomainError`](../base/#Core.DomainError) for negative [`Real`](../numbers/#Core.Real) arguments.
See also: [`exp2`](#Base.exp2), [`ldexp`](#Base.Math.ldexp), [`ispow2`](#Base.ispow2).
**Examples**


## [Mathematical Functions](#Mathematical-Functions)
```julia-repl
julia> log2(4)
2.0

julia> log2(10)
3.321928094887362

julia> log2(-2)
ERROR: DomainError with -2.0:
log2 was called with a negative real argument but will only return a complex result if called with a complex argument. Try log2(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64) at ./math.jl:31
[...]

julia> log2.(2.0 .^ (-1:1))
3-element Vector{Float64}:
 -1.0
  0.0
  1.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L527-L556)
```julia
log10(x)
```
Compute the logarithm of `x` to base 10. Throws [`DomainError`](../base/#Core.DomainError) for negative [`Real`](../numbers/#Core.Real) arguments.
**Examples**
```julia-repl
julia> log10(100)
2.0

julia> log10(2)
0.3010299956639812

julia> log10(-2)
ERROR: DomainError with -2.0:
log10 was called with a negative real argument but will only return a complex result if called with a complex argument. Try log10(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64) at ./math.jl:31
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L559-L580)
```julia
log1p(x)
```
Accurate natural logarithm of `1+x`. Throws [`DomainError`](../base/#Core.DomainError) for [`Real`](../numbers/#Core.Real) arguments less than -1.
**Examples**


## [Mathematical Functions](#Mathematical-Functions)
```julia-repl
julia> log1p(-0.5)
-0.6931471805599453

julia> log1p(0)
0.0

julia> log1p(-2)
ERROR: DomainError with -2.0:
log1p was called with a real argument < -1 but will only return a complex result if called with a complex argument. Try log1p(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L583-L604)
```julia
frexp(val)
```
Return `(x,exp)` such that `x` has a magnitude in the interval $\[1/2, 1)$ or 0, and `val` is equal to $x \\times 2^{exp}$.
See also [`significand`](../numbers/#Base.Math.significand), [`exponent`](../numbers/#Base.Math.exponent), [`ldexp`](#Base.Math.ldexp).
**Examples**
```julia-repl
julia> frexp(6.0)
(0.75, 3)

julia> significand(6.0), exponent(6.0)  # interval [1, 2) instead
(1.5, 2)

julia> frexp(0.0), frexp(NaN), frexp(-Inf)  # exponent would give an error
((0.0, 0), (NaN, 0), (-Inf, 0))
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L1013-L1032)
```julia
exp(x)
```
Compute the natural base exponential of `x`, in other words $ℯ^x$.
See also [`exp2`](#Base.exp2), [`exp10`](#Base.exp10) and [`cis`](#Base.cis).
**Examples**
```julia-repl
julia> exp(1.0)
2.718281828459045

julia> exp(im * pi) ≈ cis(pi)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/exp.jl#L334-L349)
```julia
exp2(x)
```


## [Mathematical Functions](#Mathematical-Functions)
Compute the base 2 exponential of `x`, in other words $2^x$.
See also [`ldexp`](#Base.Math.ldexp), [`<<`](#Base.:%3C%3C).
**Examples**
```julia-repl
julia> exp2(5)
32.0

julia> 2^5
32

julia> exp2(63) > typemax(Int)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/exp.jl#L351-L369)
```julia
exp10(x)
```
Compute the base 10 exponential of `x`, in other words $10^x$.
**Examples**
```julia-repl
julia> exp10(2)
100.0

julia> 10^2
100
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/exp.jl#L372-L385)
```julia
ldexp(x, n)
```
Compute $x \\times 2^n$.
See also [`frexp`](#Base.Math.frexp), [`exponent`](../numbers/#Base.Math.exponent).
**Examples**
```julia-repl
julia> ldexp(5.0, 2)
20.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L855-L867)
```julia
modf(x)
```
Return a tuple `(fpart, ipart)` of the fractional and integral parts of a number. Both parts have the same sign as the argument.
**Examples**
```julia-repl
julia> modf(3.5)
(0.5, 3.0)

julia> modf(-3.5)
(-0.5, -3.0)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L1119-L1133)
```julia
expm1(x)
```
Accurately compute $e^x-1$. It avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small values of x.
**Examples**
```julia-repl
julia> expm1(1e-16)
1.0e-16

julia> exp(1e-16) - 1
0.0
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/exp.jl#L490-L503)
```julia
round([T,] x, [r::RoundingMode])
round(x, [r::RoundingMode]; digits::Integer=0, base = 10)
round(x, [r::RoundingMode]; sigdigits::Integer, base = 10)
```
Rounds the number `x`.
Without keyword arguments, `x` is rounded to an integer value, returning a value of type `T`, or of the same type of `x` if no `T` is provided. An [`InexactError`](../base/#Core.InexactError) will be thrown if the value is not representable by `T`, similar to [`convert`](../base/#Base.convert).
If the `digits` keyword argument is provided, it rounds to the specified number of digits after the decimal place (or before if negative), in base `base`.
If the `sigdigits` keyword argument is provided, it rounds to the specified number of significant digits, in base `base`.
The [`RoundingMode`](#Base.Rounding.RoundingMode) `r` controls the direction of the rounding; the default is [`RoundNearest`](#Base.Rounding.RoundNearest), which rounds to the nearest integer, with ties (fractional values of 0.5) being rounded to the nearest even integer. Note that `round` may give incorrect results if the global rounding mode is changed (see [`rounding`](../numbers/#Base.Rounding.rounding)).


## [Mathematical Functions](#Mathematical-Functions)
When rounding to a floating point type, will round to integers representable by that type (and Inf) rather than true integers. Inf is treated as one ulp greater than the `floatmax(T)` for purposes of determining "nearest", similar to [`convert`](../base/#Base.convert).
**Examples**
```julia-repl
julia> round(1.7)
2.0

julia> round(Int, 1.7)
2

julia> round(1.5)
2.0

julia> round(2.5)
2.0

julia> round(pi; digits=2)
3.14

julia> round(pi; digits=3, base=2)
3.125

julia> round(123.456; sigdigits=2)
120.0

julia> round(357.913; sigdigits=4, base=2)
352.0

julia> round(Float16, typemax(UInt128))
Inf16

julia> floor(Float16, typemax(UInt128))
Float16(6.55e4)
```
Rounding to specified digits in bases other than 2 can be inexact when operating on binary floating point numbers. For example, the [`Float64`](../numbers/#Core.Float64) value represented by `1.15` is actually *less* than 1.15, yet will be rounded to 1.2. For example:
```julia-repl
julia> x = 1.15
1.15

julia> big(1.15)
1.149999999999999911182158029987476766109466552734375

julia> x < 115//100
true

julia> round(x, digits=1)
1.2
```
**Extensions**
To extend `round` to new numeric types, it is typically sufficient to define `Base.round(x::NewType, r::RoundingMode)`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L319-L401)
```julia
RoundingMode
```


## [Mathematical Functions](#Mathematical-Functions)
A type used for controlling the rounding mode of floating point operations (via [`rounding`](../numbers/#Base.Rounding.rounding)/[`setrounding`](../numbers/#Base.Rounding.setrounding-Tuple%7BType,%20Any%7D) functions), or as optional arguments for rounding to the nearest integer (via the [`round`](#Base.round) function).
Currently supported rounding modes are:
-   [`RoundNearest`](#Base.Rounding.RoundNearest) (default)
-   [`RoundNearestTiesAway`](#Base.Rounding.RoundNearestTiesAway)
-   [`RoundNearestTiesUp`](#Base.Rounding.RoundNearestTiesUp)
-   [`RoundToZero`](#Base.Rounding.RoundToZero)
-   [`RoundFromZero`](#Base.Rounding.RoundFromZero)
-   [`RoundUp`](#Base.Rounding.RoundUp)
-   [`RoundDown`](#Base.Rounding.RoundDown)
`RoundFromZero` requires at least Julia 1.9. Prior versions support `RoundFromZero` for `BigFloat`s only.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L26-L47)
```julia
RoundNearest
```
The default rounding mode. Rounds to the nearest integer, with ties (fractional values of 0.5) being rounded to the nearest even integer.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L50-L55)
```julia
RoundNearestTiesAway
```
Rounds to nearest integer, with ties rounded away from zero (C/C++ [`round`](#Base.round) behaviour).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L96-L101)
```julia
RoundNearestTiesUp
```


## [Mathematical Functions](#Mathematical-Functions)
Rounds to nearest integer, with ties rounded toward positive infinity (Java/JavaScript [`round`](#Base.round) behaviour).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L104-L109)
```julia
RoundToZero
```
[`round`](#Base.round) using this rounding mode is an alias for [`trunc`](#Base.trunc).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L58-L62)
```julia
RoundFromZero
```
Rounds away from zero.
`RoundFromZero` requires at least Julia 1.9. Prior versions support `RoundFromZero` for `BigFloat`s only.
**Examples**
```julia-repl
julia> BigFloat("1.0000000000000001", 5, RoundFromZero)
1.06
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L79-L93)
```julia
RoundUp
```
[`round`](#Base.round) using this rounding mode is an alias for [`ceil`](#Base.ceil).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L65-L69)
```julia
RoundDown
```
[`round`](#Base.round) using this rounding mode is an alias for [`floor`](#Base.floor).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L72-L76)
```julia
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]])
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]]; digits=0, base=10)
round(z::Complex[, RoundingModeReal, [RoundingModeImaginary]]; sigdigits, base=10)
```


## [Mathematical Functions](#Mathematical-Functions)
Return the nearest integral value of the same type as the complex-valued `z` to `z`, breaking ties using the specified [`RoundingMode`](#Base.Rounding.RoundingMode)s. The first [`RoundingMode`](#Base.Rounding.RoundingMode) is used for rounding the real components while the second is used for rounding the imaginary components.
`RoundingModeReal` and `RoundingModeImaginary` default to [`RoundNearest`](#Base.Rounding.RoundNearest), which rounds to the nearest integer, with ties (fractional values of 0.5) being rounded to the nearest even integer.
**Examples**
```julia-repl
julia> round(3.14 + 4.5im)
3.0 + 4.0im

julia> round(3.14 + 4.5im, RoundUp, RoundNearestTiesUp)
4.0 + 5.0im

julia> round(3.14159 + 4.512im; digits = 1)
3.1 + 4.5im

julia> round(3.14159 + 4.512im; sigdigits = 3)
3.14 + 4.51im
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/complex.jl#L1082-L1111)
```julia
ceil([T,] x)
ceil(x; digits::Integer= [, base = 10])
ceil(x; sigdigits::Integer= [, base = 10])
```
`ceil(x)` returns the nearest integral value of the same type as `x` that is greater than or equal to `x`.
`ceil(T, x)` converts the result to type `T`, throwing an `InexactError` if the ceiled value is not representable as a `T`.
Keywords `digits`, `sigdigits` and `base` work as for [`round`](#Base.round).
To support `ceil` for a new type, define `Base.round(x::NewType, ::RoundingMode{:Up})`.


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L452-L466)
```julia
floor([T,] x)
floor(x; digits::Integer= [, base = 10])
floor(x; sigdigits::Integer= [, base = 10])
```
`floor(x)` returns the nearest integral value of the same type as `x` that is less than or equal to `x`.
`floor(T, x)` converts the result to type `T`, throwing an `InexactError` if the floored value is not representable a `T`.
Keywords `digits`, `sigdigits` and `base` work as for [`round`](#Base.round).
To support `floor` for a new type, define `Base.round(x::NewType, ::RoundingMode{:Down})`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L435-L449)
```julia
trunc([T,] x)
trunc(x; digits::Integer= [, base = 10])
trunc(x; sigdigits::Integer= [, base = 10])
```
`trunc(x)` returns the nearest integral value of the same type as `x` whose absolute value is less than or equal to the absolute value of `x`.
`trunc(T, x)` converts the result to type `T`, throwing an `InexactError` if the truncated value is not representable a `T`.
Keywords `digits`, `sigdigits` and `base` work as for [`round`](#Base.round).
To support `trunc` for a new type, define `Base.round(x::NewType, ::RoundingMode{:ToZero})`.
See also: [`%`](#Base.rem), [`floor`](#Base.floor), [`unsigned`](../numbers/#Base.unsigned), [`unsafe_trunc`](#Base.unsafe_trunc).
**Examples**
```julia-repl
julia> trunc(2.22)
2.0

julia> trunc(-2.22, digits=1)
-2.2

julia> trunc(Int, -2.22)
-2
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/rounding.jl#L404-L432)
```julia
unsafe_trunc(T, x)
```
Return the nearest integral value of type `T` whose absolute value is less than or equal to the absolute value of `x`. If the value is not representable by `T`, an arbitrary value will be returned. See also [`trunc`](#Base.trunc).
**Examples**
```julia-repl
julia> unsafe_trunc(Int, -2.2)
-2

julia> unsafe_trunc(Int, NaN)
-9223372036854775808
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/float.jl#L395-L411)
```julia
min(x, y, ...)
```
Return the minimum of the arguments, with respect to [`isless`](../base/#Base.isless). If any of the arguments is [`missing`](../../manual/missing/#missing), return `missing`. See also the [`minimum`](../collections/#Base.minimum) function to take the minimum element from a collection.
**Examples**
```julia-repl
julia> min(2, 5, 1)
1

julia> min(4, missing, 6)
missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L483-L498)
```julia
max(x, y, ...)
```
Return the maximum of the arguments, with respect to [`isless`](../base/#Base.isless). If any of the arguments is [`missing`](../../manual/missing/#missing), return `missing`. See also the [`maximum`](../collections/#Base.maximum) function to take the maximum element from a collection.
**Examples**
```julia-repl
julia> max(2, 5, 1)
5

julia> max(5, missing, 6)
missing
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L465-L480)
```julia
minmax(x, y)
```
Return `(min(x,y), max(x,y))`.
See also [`extrema`](../collections/#Base.extrema) that returns `(minimum(x), maximum(x))`.
**Examples**
```julia-repl
julia> minmax('c','b')
('b', 'c')
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/operators.jl#L501-L513)
```julia
clamp(x, lo, hi)
```
Return `x` if `lo <= x <= hi`. If `x > hi`, return `hi`. If `x < lo`, return `lo`. Arguments are promoted to a common type.
See also [`clamp!`](#Base.clamp!), [`min`](#Base.min), [`max`](#Base.max).
`missing` as the first argument requires at least Julia 1.3.
**Examples**
```julia-repl
julia> clamp.([pi, 1.0, big(10)], 2.0, 9.0)
3-element Vector{BigFloat}:
 3.141592653589793238462643383279502884197169399375105820974944592307816406286198
 2.0
 9.0

julia> clamp.([11, 8, 5], 10, 6)  # an example where lo > hi
3-element Vector{Int64}:
  6
  6
 10
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/intfuncs.jl#L1240-L1265)
```julia
clamp(x, T)::T
```
Clamp `x` between `typemin(T)` and `typemax(T)` and convert the result to type `T`.
See also [`trunc`](#Base.trunc).
**Examples**
```julia-repl
julia> clamp(200, Int8)
127

julia> clamp(-200, Int8)
-128

julia> trunc(Int, 4pi^2)
39
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/intfuncs.jl#L1271-L1289)


## [Mathematical Functions](#Mathematical-Functions)
```julia
clamp(x::Integer, r::AbstractUnitRange)
```
Clamp `x` to lie within range `r`.
This method requires at least Julia 1.6.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/intfuncs.jl#L1329-L1336)
```julia
clamp!(array::AbstractArray, lo, hi)
```
Restrict values in `array` to the specified range, in-place. See also [`clamp`](#Base.clamp).
`missing` entries in `array` require at least Julia 1.3.
**Examples**
```julia-repl
julia> row = collect(-4:4)';

julia> clamp!(row, 0, Inf)
1×9 adjoint(::Vector{Int64}) with eltype Int64:
 0  0  0  0  0  1  2  3  4

julia> clamp.((-4:4)', 0, Inf)
1×9 Matrix{Float64}:
 0.0  0.0  0.0  0.0  0.0  1.0  2.0  3.0  4.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/intfuncs.jl#L1300-L1321)
```julia
abs(x)
```
The absolute value of `x`.
When `abs` is applied to signed integers, overflow may occur, resulting in the return of a negative value. This overflow occurs only when `abs` is applied to the minimum representable value of a signed integer. That is, when `x == typemin(typeof(x))`, `abs(x) == x < 0`, not `-x` as might be expected.
See also: [`abs2`](#Base.abs2), [`unsigned`](../numbers/#Base.unsigned), [`sign`](#Base.sign).
**Examples**
```julia-repl
julia> abs(-3)
3

julia> abs(1 + im)
1.4142135623730951

julia> abs.(Int8[-128 -127 -126 0 126 127])  # overflow at typemin(Int8)
1×6 Matrix{Int8}:
 -128  127  126  0  126  127

julia> maximum(abs, [1, -2, 3, -4])
4
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/int.jl#L156-L184)
```julia
Checked
```
The Checked module provides arithmetic functions for the built-in signed and unsigned Integer types which throw an error when an overflow occurs. They are named like `checked_sub`, `checked_div`, etc. In addition, `add_with_overflow`, `sub_with_overflow`, `mul_with_overflow` return both the unchecked results and a boolean value denoting the presence of an overflow.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L5-L12)
```julia
Base.checked_abs(x)
```
Calculates `abs(x)`, checking for overflow errors where applicable. For example, standard two's complement signed integers (e.g. `Int`) cannot represent `abs(typemin(Int))`, thus leading to an overflow.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L113-L121)
```julia
Base.checked_neg(x)
```
Calculates `-x`, checking for overflow errors where applicable. For example, standard two's complement signed integers (e.g. `Int`) cannot represent `-typemin(Int)`, thus leading to an overflow.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L85-L93)
```julia
Base.checked_add(x, y)
```


## [Mathematical Functions](#Mathematical-Functions)
Calculates `x+y`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L165-L171)
```julia
Base.checked_sub(x, y)
```
Calculates `x-y`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L222-L228)
```julia
Base.checked_mul(x, y)
```
Calculates `x*y`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L287-L293)
```julia
Base.checked_div(x, y)
```
Calculates `div(x,y)`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L316-L322)
```julia
Base.checked_rem(x, y)
```
Calculates `x%y`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L325-L331)
```julia
Base.checked_fld(x, y)
```
Calculates `fld(x,y)`, checking for overflow errors where applicable.


## [Mathematical Functions](#Mathematical-Functions)
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L334-L340)
```julia
Base.checked_mod(x, y)
```
Calculates `mod(x,y)`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L343-L349)
```julia
Base.checked_cld(x, y)
```
Calculates `cld(x,y)`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L352-L358)
```julia
Base.checked_pow(x, y)
```
Calculates `^(x,y)`, checking for overflow errors where applicable.
The overflow protection may impose a perceptible performance penalty.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L361-L367)
```julia
Base.add_with_overflow(x, y) -> (r, f)
```
Calculates `r = x+y`, with the flag `f` indicating whether overflow has occurred.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L135-L139)
```julia
Base.sub_with_overflow(x, y) -> (r, f)
```
Calculates `r = x-y`, with the flag `f` indicating whether overflow has occurred.


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L197-L201)
```julia
Base.mul_with_overflow(x, y) -> (r, f)
```
Calculates `r = x*y`, with the flag `f` indicating whether overflow has occurred.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/checked.jl#L237-L241)
```julia
abs2(x)
```
Squared absolute value of `x`.
This can be faster than `abs(x)^2`, especially for complex numbers where `abs(x)` requires a square root via [`hypot`](#Base.Math.hypot).
See also [`abs`](#Base.abs), [`conj`](#Base.conj), [`real`](#Base.real).
**Examples**
```julia-repl
julia> abs2(-3)
9

julia> abs2(3.0 + 4.0im)
25.0

julia> sum(abs2, [1+2im, 3+4im])  # LinearAlgebra.norm(x)^2
30
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/number.jl#L166-L187)
```julia
copysign(x, y) -> z
```
Return `z` which has the magnitude of `x` and the same sign as `y`.
**Examples**
```julia-repl
julia> copysign(1, -2)
-1

julia> copysign(-1, 2)
1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/number.jl#L207-L220)
```julia
sign(x)
```
Return zero if `x==0` and $x/\|x\|$ otherwise (i.e., ±1 for real `x`).
See also [`signbit`](#Base.signbit), [`zero`](../numbers/#Base.zero), [`copysign`](#Base.copysign), [`flipsign`](#Base.flipsign).
**Examples**
```julia-repl
julia> sign(-4.0)
-1.0

julia> sign(99)
1

julia> sign(-0.0)
-0.0

julia> sign(0 + im)
0.0 + 1.0im
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/number.jl#L139-L160)
```julia
signbit(x)
```
Return `true` if the value of the sign of `x` is negative, otherwise `false`.
See also [`sign`](#Base.sign) and [`copysign`](#Base.copysign).
**Examples**
```julia-repl
julia> signbit(-4)
true

julia> signbit(5)
false

julia> signbit(5.5)
false

julia> signbit(-4.1)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/number.jl#L115-L136)
```julia
flipsign(x, y)
```
Return `x` with its sign flipped if `y` is negative. For example `abs(x) = flipsign(x,x)`.
**Examples**
```julia-repl
julia> flipsign(5, 3)
5

julia> flipsign(5, -3)
-5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/number.jl#L191-L204)
```julia
sqrt(x)
```
Return $\\sqrt{x}$.
Throws [`DomainError`](../base/#Core.DomainError) for negative [`Real`](../numbers/#Core.Real) arguments. Use complex negative arguments instead. Note that `sqrt` has a branch cut along the negative real axis.
The prefix operator `√` is equivalent to `sqrt`.
See also: [`hypot`](#Base.Math.hypot).
**Examples**


## [Mathematical Functions](#Mathematical-Functions)
```julia-repl
julia> sqrt(big(81))
9.0

julia> sqrt(big(-81))
ERROR: DomainError with -81.0:
NaN result for non-NaN input.
Stacktrace:
 [1] sqrt(::BigFloat) at ./mpfr.jl:501
[...]

julia> sqrt(big(complex(-81)))
0.0 + 9.0im

julia> sqrt(-81 - 0.0im)  # -0.0im is below the branch cut
0.0 - 9.0im

julia> .√(1:4)
4-element Vector{Float64}:
 1.0
 1.4142135623730951
 1.7320508075688772
 2.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L612-L650)
```julia
isqrt(n::Integer)
```
Integer square root: the largest integer `m` such that `m*m <= n`.
```julia-repl
julia> isqrt(5)
2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/intfuncs.jl#L1090-L1099)
```julia
cbrt(x::Real)
```
Return the cube root of `x`, i.e. $x^{1/3}$. Negative values are accepted (returning the negative real root when $x \< 0$).
The prefix operator `∛` is equivalent to `cbrt`.
**Examples**
```julia-repl
julia> cbrt(big(27))
3.0

julia> cbrt(big(-27))
-3.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/special/cbrt.jl#L17-L33)
```julia
real(z)
```
Return the real part of the complex number `z`.
See also: [`imag`](#Base.imag), [`reim`](#Base.reim), [`complex`](../numbers/#Base.complex-Tuple%7BComplex%7D), [`isreal`](../numbers/#Base.isreal), [`Real`](../numbers/#Core.Real).
**Examples**
```julia-repl
julia> real(1 + 3im)
1
```


## [Mathematical Functions](#Mathematical-Functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/complex.jl#L59-L71)
```julia
real(T::Type)
```
Return the type that represents the real part of a value of type `T`. e.g: for `T == Complex{R}`, returns `R`. Equivalent to `typeof(real(zero(T)))`.
**Examples**
```julia-repl
julia> real(Complex{Int})
Int64

julia> real(Float64)
Float64
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/complex.jl#L104-L119)
```julia
real(A::AbstractArray)
```
Return an array containing the real part of each entry in array `A`.
Equivalent to `real.(A)`, except that when `eltype(A) <: Real` `A` is returned without copying, and that when `A` has zero dimensions, a 0-dimensional array is returned (rather than a scalar).
**Examples**
```julia-repl
julia> real([1, 2im, 3 + 4im])
3-element Vector{Int64}:
 1
 0
 3

julia> real(fill(2 - im))
0-dimensional Array{Int64, 0}:
2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L149-L170)
```julia
imag(z)
```
Return the imaginary part of the complex number `z`.
See also: [`conj`](#Base.conj), [`reim`](#Base.reim), [`adjoint`](../../stdlib/LinearAlgebra/#Base.adjoint), [`angle`](#Base.angle).
**Examples**
```julia-repl
julia> imag(1 + 3im)
3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/complex.jl#L74-L86)
```julia
imag(A::AbstractArray)
```


## [Mathematical Functions](#Mathematical-Functions)
Return an array containing the imaginary part of each entry in array `A`.
Equivalent to `imag.(A)`, except that when `A` has zero dimensions, a 0-dimensional array is returned (rather than a scalar).
**Examples**
```julia-repl
julia> imag([1, 2im, 3 + 4im])
3-element Vector{Int64}:
 0
 2
 4

julia> imag(fill(2 - im))
0-dimensional Array{Int64, 0}:
-1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L174-L194)
```julia
reim(z)
```
Return a tuple of the real and imaginary parts of the complex number `z`.
**Examples**
```julia-repl
julia> reim(1 + 3im)
(1, 3)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/complex.jl#L91-L101)
```julia
reim(A::AbstractArray)
```
Return a tuple of two arrays containing respectively the real and the imaginary part of each entry in `A`.
Equivalent to `(real.(A), imag.(A))`, except that when `eltype(A) <: Real` `A` is returned without copying to represent the real part, and that when `A` has zero dimensions, a 0-dimensional array is returned (rather than a scalar).
**Examples**
```julia-repl
julia> reim([1, 2im, 3 + 4im])
([1, 0, 3], [0, 2, 4])

julia> reim(fill(2 - im))
(fill(2), fill(-1))
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L198-L216)
```julia
conj(z)
```
Compute the complex conjugate of a complex number `z`.