| Supertypes | |
|---|---|
| Self type |
Remainder of the division of X by Y.
import compiletime.ops.int._ val mod: 5 % 2 = 1
Multiplication of two Int singleton types.
import compiletime.ops.int._ val mul: 4 * 2 = 8
Addition of two Int singleton types.
import compiletime.ops.int._ val sum: 2 + 2 = 4
Subtraction of two Int singleton types.
import compiletime.ops.int._ val sub: 4 - 2 = 2
Integer division of two Int singleton types.
import compiletime.ops.int._ val div: 5 / 2 = 2
Less-than comparison of two Int singleton types.
import compiletime.ops.int._ val lt1: 4 < 2 = false val lt2: 2 < 4 = true
Binary left shift of X by Y.
import compiletime.ops.int._ val lshift: 1 << 2 = 4
Less-or-equal comparison of two Int singleton types.
import compiletime.ops.int._ val lt1: 4 <= 2 = false val lt2: 2 <= 2 = true
Greater-than comparison of two Int singleton types.
import compiletime.ops.int._ val gt1: 4 > 2 = true val gt2: 2 > 2 = false
Greater-or-equal comparison of two Int singleton types.
import compiletime.ops.int._ val ge1: 4 >= 2 = true val ge2: 2 >= 3 = false
Binary right shift of X by Y.
import compiletime.ops.int._ val rshift: 10 >> 1 = 5
Binary right shift of X by Y, filling the left with zeros.
import compiletime.ops.int._ val rshiftzero: 10 >>> 1 = 5
Absolute value of an Int singleton type.
import compiletime.ops.int._ val abs: Abs[-1] = 1
Bitwise and of X and Y.
import compiletime.ops.int._ val and1: BitwiseAnd[4, 4] = 4 val and2: BitwiseAnd[10, 5] = 0
Bitwise or of X and Y.
import compiletime.ops.int._ val or: BitwiseOr[10, 11] = 11
Maximum of two Int singleton types.
import compiletime.ops.int._ val max: Max[-1, 1] = 1
Minimum of two Int singleton types.
import compiletime.ops.int._ val min: Min[-1, 1] = -1
Negation of an Int singleton type.
import compiletime.ops.int._ val neg1: Negate[-1] = 1 val neg2: Negate[1] = -1
Number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified Int singleton type. Returns 32 if the specified singleton type has no one-bits in its two's complement representation, in other words if it is equal to zero.
import compiletime.ops.int._ val zero_lzc: NumberOfLeadingZeros[0] = 32 val eight_lzc: NumberOfLeadingZeros[8] = 28 type Log2[N <: Int] = 31 - NumberOfLeadingZeros[N] val log2of8: Log2[8] = 3
Successor of a natural number where zero is the type 0 and successors are reduced as if the definition was:
import compiletime.ops.int._
type S[N <: Int] <: Int = N match {
case 0 => 1
case 1 => 2
case 2 => 3
// ...
case 2147483646 => 2147483647
}
Double conversion of an Int singleton type.
import compiletime.ops.int._ val x: ToDouble[1] = 1.0
Float conversion of an Int singleton type.
import compiletime.ops.int._ val x: ToFloat[1] = 1.0f
Long conversion of an Int singleton type.
import compiletime.ops.int._ val x: ToLong[1] = 1L
Bitwise xor of X and Y.
import compiletime.ops.int._ val xor: 10 ^ 30 = 20
© 2002-2022 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://scala-lang.org/api/3.2.0/scala/compiletime/ops/int$.html