Class IntegerSpec
Describes the size and signedness of an integer. Signed integers are assumed to use a two's complement scheme.
Implements
Inherited Members
Namespace: Flame.Constants
Assembly: Flame.dll
Syntax
public sealed class IntegerSpec : IEquatable<IntegerSpec>
Constructors
| Edit this page View SourceIntegerSpec(int, bool)
Creates an integer size from the given number of bits, and signedness.
Declaration
public IntegerSpec(int size, bool isSigned)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | |
| bool | isSigned |
Properties
| Edit this page View SourceDataSize
Gets the number of bits this integer represents, minus the sign bit, if there is a sign bit.
Declaration
public int DataSize { get; }
Property Value
| Type | Description |
|---|---|
| int |
Int16
Gets the integer spec for 16-bit signed integers.
Declaration
public static IntegerSpec Int16 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
Int32
Gets the integer spec for 32-bit signed integers.
Declaration
public static IntegerSpec Int32 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
Int64
Gets the integer spec for 64-bit signed integers.
Declaration
public static IntegerSpec Int64 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
Int8
Gets the integer spec for 8-bit signed integers.
Declaration
public static IntegerSpec Int8 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
IsSigned
Gets a boolean value that tells if conforming integers have a sign bit or not.
Declaration
public bool IsSigned { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MaxValue
Gets the biggest integer for this spec.
Declaration
public BigInteger MaxValue { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
MinValue
Gets the smallest integer for this spec.
Declaration
public BigInteger MinValue { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
Modulus
Gets the modulus for this integer spec: two to the power of the number of data bits.
Declaration
public BigInteger Modulus { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
SignedVariant
Gets the signed variant of this integer spec, that is, a signed integer spec of the same size as this integer spec.
Declaration
public IntegerSpec SignedVariant { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec | A signed integer spec of the same size as this integer spec. |
Size
Gets the integer size, in bits.
Declaration
public int Size { get; }
Property Value
| Type | Description |
|---|---|
| int |
UInt1
Gets the integer spec for 1-bit unsigned integers.
Declaration
public static IntegerSpec UInt1 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
UInt16
Gets the integer spec for 16-bit unsigned integers.
Declaration
public static IntegerSpec UInt16 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
UInt32
Gets the integer spec for 32-bit unsigned integers.
Declaration
public static IntegerSpec UInt32 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
UInt64
Gets the integer spec for 64-bit unsigned integers.
Declaration
public static IntegerSpec UInt64 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
UInt8
Gets the integer spec for 8-bit unsigned integers.
Declaration
public static IntegerSpec UInt8 { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec |
UnsignedModulus
Gets the modulus for this integer spec: two to the power of the number of total bits.
Declaration
public BigInteger UnsignedModulus { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
UnsignedVariant
Gets the unsigned variant of this integer spec, that is, an unsigned integer spec of the same size as this integer spec.
Declaration
public IntegerSpec UnsignedVariant { get; }
Property Value
| Type | Description |
|---|---|
| IntegerSpec | An unsigned integer spec of the same size as this integer spec. |
Methods
| Edit this page View SourceCast(BigInteger, IntegerSpec)
Casts the given integer, which currently matches the given spec, to match this spec.
Declaration
public BigInteger Cast(BigInteger value, IntegerSpec valueSpec)
Parameters
| Type | Name | Description |
|---|---|---|
| BigInteger | value | |
| IntegerSpec | valueSpec |
Returns
| Type | Description |
|---|---|
| BigInteger |
Equals(IntegerSpec)
Checks if this integer spec equals another integer spec.
Declaration
public bool Equals(IntegerSpec other)
Parameters
| Type | Name | Description |
|---|---|---|
| IntegerSpec | other | An integer spec. |
Returns
| Type | Description |
|---|---|
| bool |
|
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object other)
Parameters
| Type | Name | Description |
|---|---|---|
| object | other |
Returns
| Type | Description |
|---|---|
| bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Edit this page View SourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for the current object. |
Overrides
| Edit this page View SourceIsRepresentible(BigInteger)
Checks if the given integer is representible by an integer value that adheres to this spec.
Declaration
public bool IsRepresentible(BigInteger value)
Parameters
| Type | Name | Description |
|---|---|---|
| BigInteger | value |
Returns
| Type | Description |
|---|---|
| bool |
Normalize(BigInteger)
"Normalizes" the given value, by casting it to this integer spec, from this integer spec. The result of this operation is always representible, even if the input value is not.
Declaration
public BigInteger Normalize(BigInteger value)
Parameters
| Type | Name | Description |
|---|---|---|
| BigInteger | value |
Returns
| Type | Description |
|---|---|
| BigInteger |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents the current object. |
Overrides
| Edit this page View SourceTryParse(string, out IntegerSpec)
Tries to parse an integer spec's string representation.
Declaration
public static bool TryParse(string str, out IntegerSpec spec)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str | A string representation of an integer spec. |
| IntegerSpec | spec | A parsed integer spec. |
Returns
| Type | Description |
|---|---|
| bool |
|