value · System

UInt256

public value UInt256 : INumber<u256>, IHashable<u256>, IComparable<u256>, IToString
Tipo
value
Espacio de nombres
System
Ensamblado
System.Core
Acceso
public, miembros de u256
Archivo fuente
Primitives.ant

Herencia

Interfaces
INumber<TSelf> IHashable<TSelf> IComparable<TSelf> IToString

Propiedades

static u256 Zero { get; }
#

static read-only

static u256 One { get; }
#

static read-only

Métodos

static FromF64(f64 value) : u256
#

static

static ToF64(u256 value) : f64
#

static

ToString() : str
#
Hash() : u64
#
Equals(u256 other) : bool
#
CompareTo(u256 other) : i32
#
static Parse(str text) : u256
#

static

The integer text writes (decimal digits); a FormatError otherwise.

static TryParse(str text) : u256?
#

static

The number text writes, or null when it writes none.

Constantes

const u256 MinValue = 0
#

The smallest u256.

const u256 MaxValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935
#

The largest u256.

Código fuente

UInt256 en Antril, descompilado a partir de su Larva HIR.

System.UInt256.ant
// System.UInt256 — System.Core (decompiled from Larva HIR)

into namespace System
{
	[Primitive("u256")]
	public value UInt256 : INumber<u256>, IHashable<u256>, IComparable<u256>, IToString
	{
		public:
			/// The smallest u256.
			const u256 MinValue = 0;

			/// The largest u256.
			const u256 MaxValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;

			static FromF64(f64 value) : u256
			{
				f64 half = 3.402823669209385E+38;
				if (value < half)
					return UInt128.FromF64(value);
				f64 high = Math.Floor(value / half);
				return ((u256)UInt128.FromF64(high) << 128) + (u256)UInt128.FromF64(value - high * half);
			}

			static ToF64(u256 value) : f64 => UInt128.ToF64((u128)(value >> 128)) * 3.402823669209385E+38 + UInt128.ToF64((u128)value);

			ToString() : str => Number.FormatUnsigned(this);

			Hash() : u64 => (u64)this ^ (u64)(this >> 64) ^ (u64)(this >> 128) ^ (u64)(this >> 192);

			Equals(u256 other) : bool => this == other;

			CompareTo(u256 other) : i32 => this < other ? -1 : this > other ? 1 : 0;

			/// The integer `text` writes (decimal digits); a FormatError otherwise.
			static Parse(str text) : u256
			{
				u256? 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) : u256?
			{
				i32 length = text.Length;
				i32 start = 0;
				if (start == length)
					return null;
				u256 value = 0;
				loop (i32 i = start..length)
				{
					u8 unit = text[i];
					if (unit < 48 || unit > 57)
						return null;
					u256 digit = (u256)unit - 48;
					if (value > (115792089237316195423570985008687907853269984665640564039457584007913129639935 - digit) / 10)
						return null;
					value = value * 10 + digit;
				}
				return value;
			}

			static u256 Zero
			{
				get => 0;
			}

			static u256 One
			{
				get => 1;
			}
	}
}
Esc