Class IntegerConstant
Describes an integer value that adheres to an integer spec.
Implements
Inherited Members
Namespace: Flame.Constants
Assembly: Flame.dll
Syntax
public sealed class IntegerConstant : Constant, IEquatable<Constant>, IComparable<IntegerConstant>, IEquatable<IntegerConstant>, IComparableConstructors
| Improve this Doc View SourceIntegerConstant(Boolean)
Creates an integer value that wraps the given boolean.
Declaration
public IntegerConstant(bool value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | value | 
Remarks
The resulting integer value's spec is that of a one-bit unsigned integer.
IntegerConstant(Byte)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(byte value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Byte | value | 
IntegerConstant(Char)
Creates an integer value that wraps the given cbaracter value.
Declaration
public IntegerConstant(char value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Char | value | 
IntegerConstant(Int16)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(short value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int16 | value | 
IntegerConstant(Int32)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(int value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | value | 
IntegerConstant(Int64)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(long value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int64 | value | 
IntegerConstant(BigInteger, IntegerSpec)
Creates an integer value from the given integer and an integer spec.
Declaration
public IntegerConstant(BigInteger value, IntegerSpec spec)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Numerics.BigInteger | value | |
| IntegerSpec | spec | 
IntegerConstant(SByte)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(sbyte value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.SByte | value | 
Remarks
The resulting integer value's spec is that of a sixteen-bit unsigned integer.
IntegerConstant(UInt16)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(ushort value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt16 | value | 
IntegerConstant(UInt32)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(uint value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt32 | value | 
IntegerConstant(UInt64)
Creates an integer value that wraps the given integer.
Declaration
public IntegerConstant(ulong value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.UInt64 | value | 
Properties
| Improve this Doc View SourceAbsoluteValue
Gets this integer value's absolute value.
Declaration
public IntegerConstant AbsoluteValue { get; }Property Value
| Type | Description | 
|---|---|
| IntegerConstant | This integer value's absolute value. | 
IsEven
Gets a Boolean that tells if this integer is divisible by two.
Declaration
public bool IsEven { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsNegative
Gets a Boolean that tells if this integer is less than zero.
Declaration
public bool IsNegative { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsNonNegative
Gets a Boolean that tells if this integer is greater than or equal to zero.
Declaration
public bool IsNonNegative { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsNonPositive
Gets a Boolean that tells if this integer is less than or equal to zero.
Declaration
public bool IsNonPositive { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsOdd
Gets a Boolean that tells if this integer is not divisible by two.
Declaration
public bool IsOdd { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsPositive
Gets a Boolean that tells if this integer is greater than zero.
Declaration
public bool IsPositive { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsPowerOfTwo
Gets a Boolean that tells if this integer is a power of two.
Declaration
public bool IsPowerOfTwo { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsValid
Checks if this value is valid, i.e. it conforms to the given spec.
Declaration
public bool IsValid { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
IsZero
Gets a Boolean that tells if this integer is zero.
Declaration
public bool IsZero { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Negated
Gets the negated value of this integer. This may or may not be representible by the integer spec this value adheres to.
Declaration
public IntegerConstant Negated { get; }Property Value
| Type | Description | 
|---|---|
| IntegerConstant | 
Normalized
Gets a normalized value. A normalized value will always conform to the integer spec.
Declaration
public IntegerConstant Normalized { get; }Property Value
| Type | Description | 
|---|---|
| IntegerConstant | 
OnesComplement
Gets the one's complement of this integer.
Declaration
public IntegerConstant OnesComplement { get; }Property Value
| Type | Description | 
|---|---|
| IntegerConstant | 
Spec
Gets this integer's spec, which defines its size and signedness.
Declaration
public IntegerSpec Spec { get; }Property Value
| Type | Description | 
|---|---|
| IntegerSpec | 
TrailingZeroCount
Gets the number of trailing zero bits in this integer value
Declaration
public int TrailingZeroCount { get; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | The number of trailing zero bits in this integer value. | 
Value
Gets this integer's value.
Declaration
public BigInteger Value { get; }Property Value
| Type | Description | 
|---|---|
| System.Numerics.BigInteger | 
Methods
| Improve this Doc View SourceAdd(IntegerConstant)
Adds the given integer to this integer. The result retains this integer's spec.
Declaration
public IntegerConstant Add(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
BitwiseAnd(IntegerConstant)
Applies the bitwise 'and' operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant BitwiseAnd(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
BitwiseOr(IntegerConstant)
Applies the bitwise 'or' operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant BitwiseOr(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
BitwiseXor(IntegerConstant)
Applies the bitwise 'xor' operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant BitwiseXor(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
Cast(IntegerSpec)
Casts this integer value to match the given spec.
Declaration
public IntegerConstant Cast(IntegerSpec newSpec)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerSpec | newSpec | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
CastSignedness(Boolean)
Extends or wraps this integer to match the given signedness.
Declaration
public IntegerConstant CastSignedness(bool isSigned)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | isSigned | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
CastSize(Int32)
Extends or wraps this integer to match the given number of bits.
Declaration
public IntegerConstant CastSize(int size)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | size | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
CompareTo(IntegerConstant)
Compares this integer value to the given integer value.
Declaration
public int CompareTo(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | 
CompareTo(Object)
Compares this integer value to the given object.
Declaration
public int CompareTo(object other)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | other | 
Returns
| Type | Description | 
|---|---|
| System.Int32 | 
ComputeSignedDivisionMagic()
Calculate the magic numbers required to implement a signed integer division by a constant as a sequence of multiplies, adds and shifts. Requires that the divisor not be 0, 1 or -1.
Declaration
public SignedDivisionMagic ComputeSignedDivisionMagic()Returns
| Type | Description | 
|---|---|
| SignedDivisionMagic | The magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. | 
ComputeUnsignedDivisionMagic()
Calculate the magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. Requires that the divisor not be 0.
Declaration
public UnsignedDivisionMagic ComputeUnsignedDivisionMagic()Returns
| Type | Description | 
|---|---|
| UnsignedDivisionMagic | The magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. | 
ComputeUnsignedDivisionMagic(Int32)
Calculate the magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. Requires that the divisor not be 0.
Declaration
public UnsignedDivisionMagic ComputeUnsignedDivisionMagic(int leadingZeros)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | leadingZeros | The number of upper bits in the divided value that are known to be zero. | 
Returns
| Type | Description | 
|---|---|
| UnsignedDivisionMagic | The magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. | 
Divide(IntegerConstant)
Divides this integer by the given integer. The result retains this integer's spec.
Declaration
public IntegerConstant Divide(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
Equals(Constant)
Tests if this constant is equal to another constant.
Declaration
public override bool Equals(Constant other)Parameters
| Type | Name | Description | 
|---|---|---|
| Constant | other | The other constant. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Overrides
| Improve this Doc View SourceEquals(IntegerConstant)
Tests if this integer constant equals another integer constant, both in terms of value and spec.
Declaration
public bool Equals(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | An integer constant. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Equals(Object)
Declaration
public override bool Equals(object other)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | other | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Overrides
| Improve this Doc View SourceGetHashCode()
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| System.Int32 | 
Overrides
| Improve this Doc View SourceIntegerLog(IntegerConstant)
Computes the integer logarithm of this integer value in the specified base. The integer logarithm is equal to the number of times the base can be multiplied by itself without exceeding this integer value.
Declaration
public IntegerConstant IntegerLog(IntegerConstant baseValue)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | baseValue | The base of the logarithm. | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | The integer logarithm of this integer value in the specified base. | 
IsGreaterThan(IntegerConstant)
Tests if this integer value is greater than the given value.
Declaration
public bool IsGreaterThan(IntegerConstant Other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | Other | The right-hand side of the comparison. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsGreaterThanOrEqual(IntegerConstant)
Tests if this integer value is greater than or equal to the given value.
Declaration
public bool IsGreaterThanOrEqual(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | The right-hand side of the comparison. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsLessThan(IntegerConstant)
Tests if this integer value is less than the given value.
Declaration
public bool IsLessThan(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | The right-hand side of the comparison. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
IsLessThanOrEqual(IntegerConstant)
Tests if this integer value is less than or equal to the given value.
Declaration
public bool IsLessThanOrEqual(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | The right-hand side of the comparison. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Log(Double)
Computes the logarithm of this integer value in the specified base.
Declaration
public double Log(double baseValue)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Double | baseValue | The base of the logarithm. | 
Returns
| Type | Description | 
|---|---|
| System.Double | The logarithm of this integer value in the specified base. | 
Multiply(IntegerConstant)
Multiplies the given integer with this integer. The result retains this integer's spec.
Declaration
public IntegerConstant Multiply(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
Remainder(IntegerConstant)
Computes the remainder of the division of this integer by the given integer. The result retains this integer's spec.
Declaration
public IntegerConstant Remainder(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
ShiftLeft(IntegerConstant)
Applies the bitwise left shift operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant ShiftLeft(IntegerConstant shiftAmount)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | shiftAmount | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
ShiftLeft(Int32)
Applies the bitwise left shift operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant ShiftLeft(int shiftAmount)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | shiftAmount | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
ShiftRight(IntegerConstant)
Applies the bitwise right shift operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant ShiftRight(IntegerConstant shiftAmount)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | shiftAmount | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
ShiftRight(Int32)
Applies the bitwise right shift operator to this integer and the given other integer. The result retains this integer's spec.
Declaration
public IntegerConstant ShiftRight(int shiftAmount)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | shiftAmount | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
Subtract(IntegerConstant)
Subtracts the given integer from this integer. The result retains this integer's spec.
Declaration
public IntegerConstant Subtract(IntegerConstant other)Parameters
| Type | Name | Description | 
|---|---|---|
| IntegerConstant | other | 
Returns
| Type | Description | 
|---|---|
| IntegerConstant | 
ToBoolean()
Converts this integer value to a Boolean.
Declaration
public bool ToBoolean()Returns
| Type | Description | 
|---|---|
| System.Boolean | 
ToFloat32()
Converts this integer value to a 32-bit floating point number.
Declaration
public float ToFloat32()Returns
| Type | Description | 
|---|---|
| System.Single | 
ToFloat64()
Converts this integer value to a 64-bit floating point number.
Declaration
public double ToFloat64()Returns
| Type | Description | 
|---|---|
| System.Double | 
ToInt16()
Converts this integer value to a 16-bit signed integer.
Declaration
public short ToInt16()Returns
| Type | Description | 
|---|---|
| System.Int16 | 
ToInt32()
Converts this integer value to a 32-bit signed integer.
Declaration
public int ToInt32()Returns
| Type | Description | 
|---|---|
| System.Int32 | 
ToInt64()
Converts this integer value to a 64-bit signed integer.
Declaration
public long ToInt64()Returns
| Type | Description | 
|---|---|
| System.Int64 | 
ToInt8()
Converts this integer value to an 8-bit signed integer.
Declaration
public sbyte ToInt8()Returns
| Type | Description | 
|---|---|
| System.SByte | 
ToString()
Declaration
public override string ToString()Returns
| Type | Description | 
|---|---|
| System.String | 
Overrides
ToUInt16()
Converts this integer value to a 16-bit unsigned integer.
Declaration
public ushort ToUInt16()Returns
| Type | Description | 
|---|---|
| System.UInt16 | 
ToUInt32()
Converts this integer value to a 32-bit unsigned integer.
Declaration
public uint ToUInt32()Returns
| Type | Description | 
|---|---|
| System.UInt32 | 
ToUInt64()
Converts this integer value to a 64-bit unsigned integer.
Declaration
public ulong ToUInt64()Returns
| Type | Description | 
|---|---|
| System.UInt64 | 
ToUInt8()
Converts this integer value to an 8-bit unsigned integer.
Declaration
public byte ToUInt8()Returns
| Type | Description | 
|---|---|
| System.Byte |