std/number
Every numeric type of the language: Numeric, Signed, Bits and Real, the traits their operators go through;
the sized integer types and the two floating-point types; Decimal; the conversions between all of them; and
ByteSize, a number of bytes in its units.
Reach for Int, UInt or Float - the three default-width aliases - and only name a sized type (Int8,
UInt32, ...) where a signature has to say exactly how wide a value is.
Modules
std/number/libEvery numeric type of the language: [Numeric], [Signed], [Bits] and [Real], the traits their operators go through; the sized integer types and the two floating-point types; [Decimal]; the conversions between all of them; and [ByteSize], a number of bytes in its units.
Everything
- trait
BitsThe bit operations of an integer, and the operators that are them:a & bisbitwiseAnd,a | bbitwiseOr,a ^ bbitwiseExclusiveOr,~abitwiseNot,a << nshiftedLeft(by:)anda >> nshiftedRight(by:). - type
ByteSizeA number of bytes: the size of a memory, of a volume, of a limit. - type
DecimalExact base-10 arithmetic: an unscaled whole number of any size and anInt32scale, the value being the one divided by ten to the other (docs/design/DECIMAL.md). - extend
DecimalThe zero and the one of aDecimal. - extend
DecimalThe scale of aDecimal, and rounding to one. - extend
Decimal with From<Int64>EveryInt64is aDecimalat scale0. - extend
Decimal with From<UInt64>EveryUInt64is aDecimalat scale0. - extend
Decimal with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a decimal number. - alias
FloatThe default width for a floating-point number:Float64. - type
Float32A 32-bit floating-point number: IEEE-754 binary32, rounded to the nearest one with ties to even after every operation, in both back ends and in a folded constant alike. - extend
Float32The zero and the one of aFloat32, its two infinities, and the one value for which==is never true. - extend
Float32 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a decimal number. - extend
Float32 with TryFrom<Float64, NumberRangeError>The nearestFloat32, ties to even: mostFloat64values lose digits on the way. - type
Float64A 64-bit floating-point number, and the type of a decimal literal. - extend
Float64The constants and the operations of aFloat64that read as its own, not as a function of a value. - extend
Float64 with RealFloat64is the fast [Real]: the square root, the rounding andisCloseToare its own methods already, and the trigonometry, the exponential and the logarithm are the runtime's thin wrappers over<math.h>. - extend
Float64 with Power<Int64>x ** nfor a whole exponent:2.0 ** 10and10.0 ** -3. - extend
Float64 with From<Int64>EveryInt64is representable as aFloat64. - extend
Float64 with From<Float32>EveryFloat32widens toFloat64without loss. - extend
Float64 with From<Decimal>The nearestFloat64, a tie to even, as reading the decimal's text would give it. - extend
Float64 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a decimal number. - alias
IntThe default width for a whole number:Int64. - type
Int16A 16-bit signed integer, from [Int16.minimum] to [Int16.maximum]. - extend
Int16The range of anInt16, and its zero and one. - extend
Int16 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a whole number, or does not fit anInt16. - extend
Int16 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64does not fit anInt16. - type
Int32A 32-bit signed integer, from [Int32.minimum] to [Int32.maximum]. - extend
Int32The range of anInt32, and its zero and one. - extend
Int32 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a whole number, or does not fit anInt32. - extend
Int32 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64does not fit anInt32. - type
Int64A 64-bit signed integer, and the type of an integer literal. - extend
Int64The range of anInt64, its zero and one, and reading digits in another base. - extend
Int64 with From<Int8>A narrower signed integer always fits:Int.from(byte)for anInt8. - extend
Int64 with From<Int16>A narrower signed integer always fits:Int.from(short)for anInt16. - extend
Int64 with From<Int32>A narrower signed integer always fits:Int.from(word)for anInt32. - extend
Int64 with From<UInt8>Every unsigned value below the width of anInt64fits into it:Int.from(byte)for a byte of aString. - extend
Int64 with From<UInt16>Every unsigned value below the width of anInt64fits into it. - extend
Int64 with From<UInt32>Every unsigned value below the width of anInt64fits into it. - extend
Int64 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a whole number, or does not fit anInt64. - extend
Int64 with TryFrom<UInt64, NumberRangeError>Fails with a [NumberRangeError] when theUInt64is above the largestInt64. - extend
Int64 with TryFrom<Float64, NumberRangeError>Fails with a [NumberRangeError] when theFloat64does not fit anInt64, e.g. - extend
Int64 with TryFrom<Decimal, NumberRangeError>Fails with a [NumberRangeError] unless theDecimalis a whole number that fits anInt64:19.00converts and19.5does not. - extend
Int64 with From<Char>The code point:Int.from('A')is 65. - extend
Int64A [ByteSize] of this many bytes, in either family of units. - type
Int8An 8-bit signed integer, from [Int8.minimum] to [Int8.maximum]. - extend
Int8The range of anInt8, and its zero and one. - extend
Int8 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a whole number, or does not fit anInt8. - extend
Int8 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64does not fit anInt8. - trait
Integer[Numeric] of a whole number, with its range: [Integer.minimum], [Integer.maximum], and the arithmetic that answersNoneexactly where the operator would panic. - type
NumberParseErrorWhatInt.tryFrom(text)fails with: the text is not a valid number. - type
NumberRangeErrorWhat a narrowing conversion (Int8.tryFrom,Int64.tryFrom) fails with: the value does not fit the target type. - trait
NumericThe arithmetic and comparison every number has:+,-,*,/,%,==,<, reading one from text, and its zero and its one. - trait
Real[Signed] plus the operations that need a root or an angle: the scalar of geometry, trigonometry and interpolation. - type
RoundingHow a value is cut where a digit has to go: the mode of [Decimal.rounded] and [Decimal.divided]. - trait
Signed[Numeric] plus a sign: the unary-and [Signed.absolute]. - alias
UIntThe default width for a non-negative whole number:UInt64. - type
UInt16A 16-bit unsigned integer, from0to [UInt16.maximum]. - extend
UInt16The range of aUInt16, and its zero and one. - extend
UInt16 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a non-negative whole number, or does not fit aUInt16. - extend
UInt16 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64is negative or does not fit aUInt16. - type
UInt32A 32-bit unsigned integer, from0to [UInt32.maximum]. - extend
UInt32The range of aUInt32, and its zero and one. - extend
UInt32 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a non-negative whole number, or does not fit aUInt32. - extend
UInt32 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64is negative or does not fit aUInt32. - type
UInt64A 64-bit unsigned integer, from0to [UInt64.maximum]. - extend
UInt64The range of aUInt64, its zero and one, and the two operations that wrap instead of panicking. - extend
UInt64 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a non-negative whole number, or does not fit aUInt64. - extend
UInt64 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64is negative: every other one fits aUInt64. - extend
UInt64 with TryFrom<Decimal, NumberRangeError>Fails with a [NumberRangeError] unless theDecimalis a whole number that fits aUInt64. - type
UInt8An 8-bit unsigned integer, from0to [UInt8.maximum]. - extend
UInt8The range of aUInt8, and its zero and one. - extend
UInt8 with TryFrom<String, NumberParseError>Fails with a [NumberParseError] when the text is not a non-negative whole number, or does not fit aUInt8. - extend
UInt8 with TryFrom<Int64, NumberRangeError>Fails with a [NumberRangeError] when theInt64is negative or above 255: the one way from a number to a byte.