API documentation

Types

HalfIntegers.HalfType
Half{T<:Integer} <: HalfInteger

Type for half-integers $n/2$ where $n$ is of type T.

Aliases for Half{T} are defined for all standard Signed and Unsigned integer types, so that, e.g., HalfInt can be used instead of Half{Int}:

TAlias for Half{T}
IntHalfInt
Int8HalfInt8
Int16HalfInt16
Int32HalfInt32
Int64HalfInt64
Int128HalfInt128
BigIntBigHalfInt (notHalfBigInt!)
UIntHalfUInt
UInt8HalfUInt8
UInt16HalfUInt16
UInt32HalfUInt32
UInt64HalfUInt64
UInt128HalfUInt128
HalfIntegers.HalfIntegerType
HalfInteger <: Real

Abstract supertype for half-integers. Here, every number $n/2$ where $n\in\mathbb{Z}$ is considered a half-integer, regardless of whether $n$ is even or odd.

Functions

HalfIntegers.halfMethod
half([T<:Complex{<:HalfInteger},] x)

For a complex value x with integer real and imaginary parts, return x/2 as a complex number of type T. If T is not given, return an appropriate complex number type with half-integer parts. Throw an InexactError if the real or the imaginary part of x are not integer.

HalfIntegers 1.1

missing as an argument requires at least HalfIntegers 1.1.

Examples

julia> half(3 + 2im)
3/2 + 1*im

julia> half(Complex{HalfInt32}, 1.0 + 5.0im)
1/2 + 5/2*im
HalfIntegers.halfMethod
half([T<:HalfInteger,] x)

For an integer value x, return x/2 as a half-integer of type T. If T is not given, return an appropriate HalfInteger type. Throw an InexactError if x is not an integer.

HalfIntegers 1.1

missing as an argument requires at least HalfIntegers 1.1.

Examples

julia> half(3)
3/2

julia> half(-5.0)
-5/2

julia> half(HalfInt16, 8)
4
HalfIntegers.ishalfintegerMethod
ishalfinteger(x)

Test whether x is numerically equal to some half-integer.

Examples

julia> ishalfinteger(3.5)
true

julia> ishalfinteger(2)
true

julia> ishalfinteger(1//3)
false
HalfIntegers.onehalfMethod
onehalf(x)

Return the value 1/2 in the type of x (x can also specify the type itself).

HalfIntegers 1.1

missing as an argument requires at least HalfIntegers 1.1.

HalfIntegers 1.2

Some abstract types as arguments require at least HalfIntegers 1.2.

Examples

julia> onehalf(7//3)
1//2

julia> onehalf(HalfInt)
1/2
HalfIntegers.twiceMethod
twice(x)

Return 2x. If x is a HalfInteger, return an appropriate integer type.

HalfIntegers 1.1

missing as an argument requires at least HalfIntegers 1.1.

Examples

julia> twice(2)
4

julia> twice(1.5)
3.0

julia> twice(HalfInt8(3/2))  # returns an Int8
3

julia> twice(HalfInt32(3.0) + HalfInt32(2.5)*im)  # returns a Complex{Int32}
6 + 5im
HalfIntegers.twiceMethod
twice(T<:Integer, x)
twice(T<:Complex{<:Integer}, x)

Return 2x as a number of type T.

HalfIntegers 1.1

missing as an argument requires at least HalfIntegers 1.1.

Examples

julia> twice(Int16, HalfInt(5/2))
5

julia> twice(Complex{BigInt}, HalfInt(5/2) + HalfInt(3)*im)
5 + 6im