Long

class Long : Number, Comparable<Long> (source)

Represents a 64-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type long.

Functions

and

infix fun and(other: Long): Long

Performs a bitwise AND operation between the two values.

compareTo

operator fun compareTo(other: Byte): Int
operator fun compareTo(other: Short): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: Float): Int
operator fun compareTo(other: Double): Int

Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other.

dec

operator fun dec(): Long

Decrements this value.

div

operator fun div(other: Byte): Long
operator fun div(other: Short): Long
operator fun div(other: Int): Long
operator fun div(other: Long): Long
operator fun div(other: Float): Float
operator fun div(other: Double): Double

Divides this value by the other value.

inc

operator fun inc(): Long

Increments this value.

inv

fun inv(): Long

Inverts the bits in this value.

minus

operator fun minus(other: Byte): Long
operator fun minus(other: Short): Long
operator fun minus(other: Int): Long
operator fun minus(other: Long): Long
operator fun minus(other: Float): Float
operator fun minus(other: Double): Double

Subtracts the other value from this value.

mod

operator fun mod(other: Byte): Long
operator fun mod(other: Short): Long
operator fun mod(other: Int): Long
operator fun mod(other: Long): Long
operator fun mod(other: Float): Float
operator fun mod(other: Double): Double

Calculates the remainder of dividing this value by the other value.

or

infix fun or(other: Long): Long

Performs a bitwise OR operation between the two values.

plus

operator fun plus(other: Byte): Long
operator fun plus(other: Short): Long
operator fun plus(other: Int): Long
operator fun plus(other: Long): Long
operator fun plus(other: Float): Float
operator fun plus(other: Double): Double

Adds the other value to this value.

rangeTo

operator fun rangeTo(other: Byte): LongRange
operator fun rangeTo(other: Short): LongRange
operator fun rangeTo(other: Int): LongRange
operator fun rangeTo(other: Long): LongRange

Creates a range from this value to the specified other value.

rem

operator fun rem(other: Byte): Long
operator fun rem(other: Short): Long
operator fun rem(other: Int): Long
operator fun rem(other: Long): Long
operator fun rem(other: Float): Float
operator fun rem(other: Double): Double

Calculates the remainder of dividing this value by the other value.

shl

infix fun shl(bitCount: Int): Long

Shifts this value left by the bitCount number of bits.

shr

infix fun shr(bitCount: Int): Long

Shifts this value right by the bitCount number of bits, filling the leftmost bits with copies of the sign bit.

times

operator fun times(other: Byte): Long
operator fun times(other: Short): Long
operator fun times(other: Int): Long
operator fun times(other: Long): Long
operator fun times(other: Float): Float
operator fun times(other: Double): Double

Multiplies this value by the other value.

toByte

fun toByte(): Byte

Returns the value of this number as a Byte, which may involve rounding or truncation.

toChar

fun toChar(): Char

Returns the Char with the numeric value equal to this number, truncated to 16 bits if appropriate.

toDouble

fun toDouble(): Double

Returns the value of this number as a Double, which may involve rounding.

toFloat

fun toFloat(): Float

Returns the value of this number as a Float, which may involve rounding.

toInt

fun toInt(): Int

Returns the value of this number as an Int, which may involve rounding or truncation.

toLong

fun toLong(): Long

Returns the value of this number as a Long, which may involve rounding or truncation.

toShort

fun toShort(): Short

Returns the value of this number as a Short, which may involve rounding or truncation.

unaryMinus

operator fun unaryMinus(): Long

Returns the negative of this value.

unaryPlus

operator fun unaryPlus(): Long

Returns this value.

ushr

infix fun ushr(bitCount: Int): Long

Shifts this value right by the bitCount number of bits, filling the leftmost bits with zeros.

xor

infix fun xor(other: Long): Long

Performs a bitwise XOR operation between the two values.

Companion Object Properties

MAX_VALUE

const val MAX_VALUE: Long

A constant holding the maximum value an instance of Long can have.

MIN_VALUE

const val MIN_VALUE: Long

A constant holding the minimum value an instance of Long can have.

Extension Properties

absoluteValue

actual val Long.absoluteValue: Long

Returns the absolute value of this value.

sign

actual val Long.sign: Int

Returns the sign of this value:

Extension Functions

coerceAtLeast

fun Long.coerceAtLeast(minimumValue: Long): Long

Ensures that this value is not less than the specified minimumValue.

coerceAtMost

fun Long.coerceAtMost(maximumValue: Long): Long

Ensures that this value is not greater than the specified maximumValue.

coerceIn

fun Long.coerceIn(
    minimumValue: Long,
    maximumValue: Long
): Long

Ensures that this value lies in the specified range minimumValue..maximumValue.

fun Long.coerceIn(range: ClosedRange<Long>): Long

Ensures that this value lies in the specified range.

downTo

infix fun Long.downTo(to: Byte): LongProgression
infix fun Long.downTo(to: Int): LongProgression
infix fun Long.downTo(to: Long): LongProgression
infix fun Long.downTo(to: Short): LongProgression

Returns a progression from this value down to the specified to value with the step -1.

toBigDecimal

fun Long.toBigDecimal(): BigDecimal
fun Long.toBigDecimal(mathContext: MathContext): BigDecimal

Returns the value of this Long number as a BigDecimal.

toBigInteger

fun Long.toBigInteger(): BigInteger

Returns the value of this Long number as a BigInteger.

toString

actual fun Long.toString(radix: Int): String

Returns a string representation of this Long value in the specified radix.

until

infix fun Long.until(to: Byte): LongRange
infix fun Long.until(to: Int): LongRange
infix fun Long.until(to: Long): LongRange
infix fun Long.until(to: Short): LongRange

Returns a range from this value up to but excluding the specified to value.