Numbers

Numbers

Big numbers, byte and C character types, and the ^^ operator.

Contents

NameSummary
__builtin_c_charC and C++'s plain char, a character type distinct from i8 and u8.
__builtin_c_wcharC++'s wchar_t, the CWChar lang item.
__builtin_c_char16C++'s char16_t, the CChar16 lang item.
__builtin_c_char8C++'s char8_t, the CChar8 lang item.
Operators
BigFloatThe arbitrary-precision float lang item.
BigIntThe arbitrary-precision integer lang item.

__builtin_c_char

type __builtin_c_char = u8

C and C++'s plain char, a character type distinct from i8 and u8. Users spell it std::c_char.

The u8 body is only what parses; the type is the CChar lang item, which C++ spells char.

__builtin_c_wchar

type __builtin_c_wchar = u32

C++'s wchar_t, the CWChar lang item. Users spell it std::c_wchar.

Distinct from every integer type. The u32 body is only what parses; the type store lays it out from the target (16 bits wide on Windows).

__builtin_c_char16

type __builtin_c_char16 = u16

C++'s char16_t, the CChar16 lang item. Users spell it std::c_char16.

__builtin_c_char8

type __builtin_c_char8 = u8

C++'s char8_t, the CChar8 lang item. Users spell it std::c_char8.

Operators

x ^^ n on a primitive base is lowered to a call to pow. The function is private, so it is documented here rather than called by name.

pow

fn <B: type, E: type> pow(base: B, exp: E) -> B

Implements ^^ on a primitive base: x ^^ n is lowered to pow(x, n).

Repeated squaring, so overflow is exactly *'s. A negative exponent is (1 / base) ^^ -exp under the base type's own division: for an integer base that reciprocal is 0, 1 or -1 and nothing can overflow on the way back; for a float base it is the reciprocal. The exponent negation is written -(exp + 1) rather than -exp, which has no value for the minimum.

: type rather than a bound: B and E are only ever primitives and no interface says "numeric" yet, so C++ checks this one body per instance.

See also

Lib/builtin/base/pow.k

BigFloat

struct BigFloat

The arbitrary-precision float lang item. Layout only: no operations are declared in builtin yet.

Fields: mant is the mantissa (a BigInt) and exp is the exponent.

BigInt

struct BigInt

The arbitrary-precision integer lang item. Layout only: no operations are declared in builtin yet.

Fields: limbs points at the 64-bit limbs of the magnitude, len counts them, and neg is the sign flag.

Generated from Kairo source, Apache-2.0 WITH AdditionRef-Kairo-Runtime-exception.