Integer
| Description: | Numbers without a fractional component (positive, negative, and 0) |
| Annotation: | int |
| Literal syntax: | A decimal, hex, octal, or binary numeric value without a decimal place. E.g., -100, 0, 50, +50, 0xff (hex), 0o234 (octal), 0b10101 (binary) |
| Casts: | into int |
| See also: | Types of Data - Integers |
Additional Language Notes
Integers are internally represented as signed 64-bit numbers with two's-complement arithmetic. An operation that overflows this range raises an
operator_overflowerror rather than wrapping around.Underscores can be used as digit separators in literals, e.g.
1_000_000.The
/operator always returns afloat. Use//for floor division, which returns anint.moduses the same floor semantics, so the result has the sign of the divisor:7 / 2 # => 3.5 7 // 2 # => 3 -7 // 2 # => -4 -7 mod 3 # => 2
Common commands that can be used with int
into int,into floatmathsubcommands (seehelp mathfor a list)bitssubcommands (seehelp bitsfor a list)format bitsto show the binary representation, e.g.42 | format bitsreturns00101010format number