value · System
UInt128
public value UInt128 : INumber<u128>, IHashable<u128>, IComparable<u128>, IToString
- Kind
- value
- Namespace
- System
- Assembly
- System.Core
- Access
- public, members of u128
- Source file
Primitives.ant
Inheritance
Properties
Methods
ToString() : str
#
The integer text writes (decimal digits); a FormatError otherwise.
The number text writes, or null when it writes none.
Constants
The smallest u128.
The largest u128.
Source
UInt128 as Antril, decompiled from its Larva HIR.
// System.UInt128 — System.Core (decompiled from Larva HIR)
into namespace System
{
[Primitive("u128")]
public value UInt128 : INumber<u128>, IHashable<u128>, IComparable<u128>, IToString
{
public:
/// The smallest u128.
const u128 MinValue = 0;
/// The largest u128.
const u128 MaxValue = 340282366920938463463374607431768211455;
static FromF64(f64 value) : u128
{
f64 half = 1.8446744073709552E+19;
if (value < half)
return (u64)value;
f64 high = Math.Floor(value / half);
return ((u128)(u64)high << 64) + (u128)(u64)(value - high * half);
}
static ToF64(u128 value) : f64 => (f64)(u64)(value >> 64) * 1.8446744073709552E+19 + (f64)(u64)value;
ToString() : str => Number.FormatUnsigned(this);
Hash() : u64 => (u64)this ^ (u64)(this >> 64);
Equals(u128 other) : bool => this == other;
CompareTo(u128 other) : i32 => this < other ? -1 : this > other ? 1 : 0;
/// The integer `text` writes (decimal digits); a FormatError otherwise.
static Parse(str text) : u128
{
u128? value = TryParse(text);
if (value == null)
throw new FormatError("not a number: " + text);
return value.Value;
}
/// The number `text` writes, or null when it writes none.
static TryParse(str text) : u128?
{
i32 length = text.Length;
i32 start = 0;
if (start == length)
return null;
u128 value = 0;
loop (i32 i = start..length)
{
u8 unit = text[i];
if (unit < 48 || unit > 57)
return null;
u128 digit = (u128)unit - 48;
if (value > (340282366920938463463374607431768211455 - digit) / 10)
return null;
value = value * 10 + digit;
}
return value;
}
static u128 Zero
{
get => 0;
}
static u128 One
{
get => 1;
}
}
}