PeterO.Cbor.CBORNumber
PeterO.Cbor.CBORNumber
public sealed class CBORNumber : System.IComparable
An instance of a number that CBOR or certain CBOR tags can represent. For this purpose, infinities and not-a-number or NaN values are considered numbers. Currently, this class can store one of the following kinds of numbers: 64-bit signed integers or binary floating-point numbers; or arbitrary-precision integers, decimal numbers, binary numbers, or rational numbers.
Member Summary
Abs()
- Returns the absolute value of this CBOR number.Add(PeterO.Cbor.CBORNumber)
- Returns the sum of this number and another number.CanFitInDouble()
- Returns whether this object's value can be converted to a 64-bit floating point number without its value being rounded to another numerical value.CanFitInInt32()
- Returns whether this object's numerical value is an integer, is -(2^31) or greater, and is less than 2^31.CanFitInInt64()
- Returns whether this object's numerical value is an integer, is -(2^63) or greater, and is less than 2^63.CanFitInSingle()
- Returns whether this object's value can be converted to a 32-bit floating point number without its value being rounded to another numerical value.CanFitInUInt64()
- Returns whether this object's numerical value is an integer, is 0 or greater, and is less than 2^64.CanTruncatedIntFitInInt32()
- Returns whether this object's value, converted to an integer by discarding its fractional part, would be -(2^31) or greater, and less than 2^31.CanTruncatedIntFitInInt64()
- Returns whether this object's value, converted to an integer by discarding its fractional part, would be -(2^63) or greater, and less than 2^63.CanTruncatedIntFitInUInt64()
- Returns whether this object's value, converted to an integer by discarding its fractional part, would be 0 or greater, and less than 2^64.CompareTo(int)
- Compares this CBOR number with a 32-bit signed integer.CompareTo(long)
- Compares this CBOR number with a 64-bit signed integer.CompareTo(PeterO.Cbor.CBORNumber)
- Compares this CBOR number with another.Divide(PeterO.Cbor.CBORNumber)
- Returns the quotient of this number and another number.FromByte(byte)
- Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.FromCBORObject(PeterO.Cbor.CBORObject)
- Creates a CBOR number object from a CBOR object representing a number (that is, one for which the IsNumber property in.FromInt16(short)
- Converts a 16-bit signed integer to an arbitrary-precision decimal number.IsFinite()
- Gets a value indicating whether this CBOR object represents a finite number.IsInfinity()
- Gets a value indicating whether this object represents infinity.IsInteger()
- Gets a value indicating whether this object represents an integer number, that is, a number without a fractional part.IsNaN()
- Gets a value indicating whether this object represents a not-a-number value.IsNegative()
- Gets a value indicating whether this object is a negative number.IsNegativeInfinity()
- Gets a value indicating whether this object represents negative infinity.IsPositiveInfinity()
- Gets a value indicating whether this object represents positive infinity.IsZero()
- Gets a value indicating whether this object's value equals 0.Kind
- Gets the underlying form of this CBOR number object.Multiply(PeterO.Cbor.CBORNumber)
- Returns a CBOR number expressing the product of this number and the given number.Negate()
- Returns a CBOR number with the same value as this one but with the sign reversed.bool operator >(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)
- Returns whether one object's value is greater than another's.bool operator >=(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)
- Returns whether one object's value is at least another's.bool operator <(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)
- Returns whether one object's value is less than another's.bool operator <=(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)
- Returns whether one object's value is up to another's.Remainder(PeterO.Cbor.CBORNumber)
- Returns the remainder when this number is divided by another number.Sign
- Gets this value's sign: -1 if nonzero and negative; 1 if nonzero and positive; 0 if zero.Subtract(PeterO.Cbor.CBORNumber)
- Returns a number that expresses this number minus another.ToByteChecked()
- Converts this number's value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.ToByteIfExact()
- Converts this number's value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.ToByteUnchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a byte (from 0 to 255).ToCBORObject()
- Converts this object's value to a CBOR object.ToDecimal()
- Converts this number's value to a CLR decimal.ToEDecimal()
- Converts this object to a decimal number.ToEFloat()
- Converts this object to an arbitrary-precision binary floating point number.ToEInteger()
- Converts this object to an arbitrary-precision integer.ToEIntegerIfExact()
- Converts this object to an arbitrary-precision integer if its value is an integer.ToERational()
- Converts this object to a rational number.ToInt16Checked()
- Converts this number's value to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.ToInt16IfExact()
- Converts this number's value to a 16-bit signed integer if it can fit in a 16-bit signed integer without rounding to a different numerical value.ToInt16Unchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 16-bit signed integer.ToInt32Checked()
- Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.ToInt32IfExact()
- Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.ToInt32Unchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 32-bit signed integer.ToInt64Checked()
- Converts this number's value to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.ToInt64IfExact()
- Converts this number's value to a 64-bit signed integer if it can fit in a 64-bit signed integer without rounding to a different numerical value.ToInt64Unchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 64-bit signed integer.ToSByteChecked()
- Converts this number's value to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.ToSByteIfExact()
- Converts this number's value to an 8-bit signed integer if it can fit in an 8-bit signed integer without rounding to a different numerical value.ToSByteUnchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as an 8-bit signed integer.ToString()
- Returns the value of this object in text form.ToUInt16Checked()
- Converts this number's value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.ToUInt16IfExact()
- Converts this number's value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer without rounding to a different numerical value.ToUInt16Unchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 16-bit unsigned integer.ToUInt32Checked()
- Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.ToUInt32IfExact()
- Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.ToUInt32Unchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 32-bit signed integer.ToUInt64Checked()
- Converts this number's value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.ToUInt64IfExact()
- Converts this number's value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer without rounding to a different numerical value.ToUInt64Unchecked()
- Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 64-bit unsigned integer.
Kind
public PeterO.Cbor.CBORNumber.NumberKind Kind { get; }
Gets the underlying form of this CBOR number object.
Returns:
The underlying form of this CBOR number object.
Sign
public int Sign { get; }
Gets this value's sign: -1 if nonzero and negative; 1 if nonzero and positive; 0 if zero. Not-a-number (NaN) values are positive or negative depending on what sign is stored in their underlying forms.
Returns:
This value's sign.
Abs
public PeterO.Cbor.CBORNumber Abs();
Returns the absolute value of this CBOR number.
Return Value:
This object's absolute value without its negative sign.
Add
public PeterO.Cbor.CBORNumber Add( PeterO.Cbor.CBORNumber b);
Returns the sum of this number and another number.
Parameters:
- b: The number to add with this one.
Return Value:
The sum of this number and another number.
Exceptions:
System.ArgumentNullException: The parameter b is null.
System.OutOfMemoryException: The exact result of the operation might be too big to fit in memory (or might require more than 2 gigabytes of memory to store).
CanFitInDouble
public bool CanFitInDouble();
Returns whether this object's value can be converted to a 64-bit floating point number without its value being rounded to another numerical value.
Return Value:
true
if this object's value can be converted to a 64-bit floating point number without its value being rounded to another numerical value, or if this is a not-a-number value, even if the value's diagnostic information can't fit in a 64-bit floating point number; otherwise, false
.
CanFitInInt32
public bool CanFitInInt32();
Returns whether this object's numerical value is an integer, is -(2^31) or greater, and is less than 2^31.
Return Value:
true
if this object's numerical value is an integer, is -(2^31) or greater, and is less than 2^31; otherwise, false
.
CanFitInInt64
public bool CanFitInInt64();
Returns whether this object's numerical value is an integer, is -(2^63) or greater, and is less than 2^63.
Return Value:
true
if this object's numerical value is an integer, is -(2^63) or greater, and is less than 2^63; otherwise, false
.
CanFitInSingle
public bool CanFitInSingle();
Returns whether this object's value can be converted to a 32-bit floating point number without its value being rounded to another numerical value.
Return Value:
true
if this object's value can be converted to a 32-bit floating point number without its value being rounded to another numerical value, or if this is a not-a-number value, even if the value's diagnostic information can' t fit in a 32-bit floating point number; otherwise, false
.
CanFitInUInt64
public bool CanFitInUInt64();
Returns whether this object's numerical value is an integer, is 0 or greater, and is less than 2^64.
Return Value:
true
if this object's numerical value is an integer, is 0 or greater, and is less than 2^64; otherwise, false
.
CanTruncatedIntFitInInt32
public bool CanTruncatedIntFitInInt32();
Returns whether this object's value, converted to an integer by discarding its fractional part, would be -(2^31) or greater, and less than 2^31.
Return Value:
true
if this object's value, converted to an integer by discarding its fractional part, would be -(2^31) or greater, and less than 2^31; otherwise, false
.
CanTruncatedIntFitInInt64
public bool CanTruncatedIntFitInInt64();
Returns whether this object's value, converted to an integer by discarding its fractional part, would be -(2^63) or greater, and less than 2^63.
Return Value:
true
if this object's value, converted to an integer by discarding its fractional part, would be -(2^63) or greater, and less than 2^63; otherwise, false
.
CanTruncatedIntFitInUInt64
public bool CanTruncatedIntFitInUInt64();
Returns whether this object's value, converted to an integer by discarding its fractional part, would be 0 or greater, and less than 2^64.
Return Value:
true
if this object's value, converted to an integer by discarding its fractional part, would be 0 or greater, and less than 2^64; otherwise, false
.
CompareTo
public int CompareTo( int other);
Compares this CBOR number with a 32-bit signed integer. In this implementation, the two numbers' mathematical values are compared. Here, NaN (not-a-number) is considered greater than any number.
Parameters:
- other: A value to compare with. Can be null.
Return Value:
A negative number, if this value is less than the other object; or 0, if both values are equal; or a positive number, if this value is less than the other object or if the other object is null. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency's sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
CompareTo
public int CompareTo( long other);
Compares this CBOR number with a 64-bit signed integer. In this implementation, the two numbers' mathematical values are compared. Here, NaN (not-a-number) is considered greater than any number.
Parameters:
- other: A value to compare with. Can be null.
Return Value:
A negative number, if this value is less than the other object; or 0, if both values are equal; or a positive number, if this value is less than the other object or if the other object is null. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency's sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
CompareTo
public sealed int CompareTo( PeterO.Cbor.CBORNumber other);
Compares this CBOR number with another. In this implementation, the two numbers' mathematical values are compared. Here, NaN (not-a-number) is considered greater than any number.
Parameters:
- other: A value to compare with. Can be null.
Return Value:
A negative number, if this value is less than the other object; or 0, if both values are equal; or a positive number, if this value is less than the other object or if the other object is null. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency's sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
Divide
public PeterO.Cbor.CBORNumber Divide( PeterO.Cbor.CBORNumber b);
Returns the quotient of this number and another number.
Parameters:
- b: The right-hand side (divisor) to the division operation.
Return Value:
The quotient of this number and another one.
Exceptions:
System.ArgumentNullException: The parameter b is null.
System.OutOfMemoryException: The exact result of the operation might be too big to fit in memory (or might require more than 2 gigabytes of memory to store).
FromByte
public static PeterO.Cbor.CBORNumber FromByte( byte inputByte);
Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.
Parameters:
- inputByte: The number to convert as a byte (from 0 to 255).
Return Value:
This number's value as an arbitrary-precision decimal number.
FromCBORObject
public static PeterO.Cbor.CBORNumber FromCBORObject( PeterO.Cbor.CBORObject o);
Creates a CBOR number object from a CBOR object representing a number (that is, one for which the IsNumber property in.NET or the isNumber() method in Java returns true).
Parameters:
- o: The parameter is a CBOR object representing a number.
Return Value:
A CBOR number object, or null if the given CBOR object is null or does not represent a number.
FromInt16
public static PeterO.Cbor.CBORNumber FromInt16( short inputInt16);
Converts a 16-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputInt16: The number to convert as a 16-bit signed integer.
Return Value:
This number's value as an arbitrary-precision decimal number.
IsFinite
public bool IsFinite();
Gets a value indicating whether this CBOR object represents a finite number.
Return Value:
true
if this CBOR object represents a finite number; otherwise, false
.
IsInfinity
public bool IsInfinity();
Gets a value indicating whether this object represents infinity.
Return Value:
true
if this object represents infinity; otherwise, false
.
IsInteger
public bool IsInteger();
Gets a value indicating whether this object represents an integer number, that is, a number without a fractional part. Infinity and not-a-number are not considered integers.
Return Value:
true
if this object represents an integer number, that is, a number without a fractional part; otherwise, false
.
IsNaN
public bool IsNaN();
Gets a value indicating whether this object represents a not-a-number value.
Return Value:
true
if this object represents a not-a-number value; otherwise, false
.
IsNegative
public bool IsNegative();
Gets a value indicating whether this object is a negative number.
Return Value:
true
if this object is a negative number; otherwise, false
.
IsNegativeInfinity
public bool IsNegativeInfinity();
Gets a value indicating whether this object represents negative infinity.
Return Value:
true
if this object represents negative infinity; otherwise, false
.
IsPositiveInfinity
public bool IsPositiveInfinity();
Gets a value indicating whether this object represents positive infinity.
Return Value:
true
if this object represents positive infinity; otherwise, false
.
IsZero
public bool IsZero();
Gets a value indicating whether this object's value equals 0.
Return Value:
true
if this object's value equals 0; otherwise, false
.
Multiply
public PeterO.Cbor.CBORNumber Multiply( PeterO.Cbor.CBORNumber b);
Returns a CBOR number expressing the product of this number and the given number.
Parameters:
- b: The second operand to the multiplication operation.
Return Value:
A number expressing the product of this number and the given number.
Exceptions:
System.ArgumentNullException: The parameter b is null.
System.OutOfMemoryException: The exact result of the operation might be too big to fit in memory (or might require more than 2 gigabytes of memory to store).
Negate
public PeterO.Cbor.CBORNumber Negate();
Returns a CBOR number with the same value as this one but with the sign reversed.
Return Value:
A CBOR number with the same value as this one but with the sign reversed.
Operator >
public static bool operator >( PeterO.Cbor.CBORNumber a, PeterO.Cbor.CBORNumber b);
Returns whether one object's value is greater than another's.
Parameters:
a: The left-hand side of the comparison.
b: The right-hand side of the comparison.
Return Value:
true
if one object's value is greater than another's; otherwise, false
.
Exceptions:
- System.ArgumentNullException: The parameter a is null.
Operator >=
public static bool operator >=( PeterO.Cbor.CBORNumber a, PeterO.Cbor.CBORNumber b);
Returns whether one object's value is at least another's.
Parameters:
a: The left-hand side of the comparison.
b: The right-hand side of the comparison.
Return Value:
true
if one object's value is at least another's; otherwise, false
.
Exceptions:
- System.ArgumentNullException: The parameter a is null.
Operator <
public static bool operator <( PeterO.Cbor.CBORNumber a, PeterO.Cbor.CBORNumber b);
Returns whether one object's value is less than another's.
Parameters:
a: The left-hand side of the comparison.
b: The right-hand side of the comparison.
Return Value:
true
if the first object's value is less than the other's; otherwise, false
.
Exceptions:
- System.ArgumentNullException: The parameter a is null.
Operator <=
public static bool operator <=( PeterO.Cbor.CBORNumber a, PeterO.Cbor.CBORNumber b);
Returns whether one object's value is up to another's.
Parameters:
a: The left-hand side of the comparison.
b: The right-hand side of the comparison.
Return Value:
true
if one object's value is up to another's; otherwise, false
.
Exceptions:
- System.ArgumentNullException: The parameter a is null.
Remainder
public PeterO.Cbor.CBORNumber Remainder( PeterO.Cbor.CBORNumber b);
Returns the remainder when this number is divided by another number.
Parameters:
- b: The right-hand side (dividend) of the remainder operation.
Return Value:
The remainder when this number is divided by the other number.
Exceptions:
System.ArgumentNullException: The parameter b is null.
System.OutOfMemoryException: The exact result of the operation might be too big to fit in memory (or might require more than 2 gigabytes of memory to store).
Subtract
public PeterO.Cbor.CBORNumber Subtract( PeterO.Cbor.CBORNumber b);
Returns a number that expresses this number minus another.
Parameters:
- b: The second operand to the subtraction.
Return Value:
A CBOR number that expresses this number minus the given number.
Exceptions:
System.ArgumentNullException: The parameter b is null.
System.OutOfMemoryException: The exact result of the operation might be too big to fit in memory (or might require more than 2 gigabytes of memory to store).
ToByteChecked
public byte ToByteChecked();
Converts this number's value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a byte (from 0 to 255).
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 255.
ToByteIfExact
public byte ToByteIfExact();
Converts this number's value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.
Return Value:
This number's value as a byte (from 0 to 255).
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 255.
ToByteUnchecked
public byte ToByteUnchecked();
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a byte (from 0 to 255).
Return Value:
This number, converted to a byte (from 0 to 255). Returns 0 if this value is infinity or not-a-number.
ToCBORObject
public PeterO.Cbor.CBORObject ToCBORObject();
Converts this object's value to a CBOR object.
Return Value:
A CBOR object that stores this object's value.
ToDecimal
public decimal ToDecimal();
Converts this number's value to a CLR decimal.
Return Value:
This number's value, converted to a decimal as though by (decimal)this.ToEDecimal()
.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number.
ToEDecimal
public PeterO.Numbers.EDecimal ToEDecimal();
Converts this object to a decimal number.
Return Value:
A decimal number for this object's value.
ToEFloat
public PeterO.Numbers.EFloat ToEFloat();
Converts this object to an arbitrary-precision binary floating point number. See the ToObject overload taking a type for more information.
Return Value:
An arbitrary-precision binary floating-point number for this object's value.
ToEInteger
public PeterO.Numbers.EInteger ToEInteger();
Converts this object to an arbitrary-precision integer. See the ToObject overload taking a type for more information.
Return Value:
The closest arbitrary-precision integer to this object.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number.
ToEIntegerIfExact
public PeterO.Numbers.EInteger ToEIntegerIfExact();
Converts this object to an arbitrary-precision integer if its value is an integer.
Return Value:
The arbitrary-precision integer given by object.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number or is not an exact integer.
ToERational
public PeterO.Numbers.ERational ToERational();
Converts this object to a rational number. See the ToObject overload taking a type for more information.
Return Value:
A rational number for this object's value.
ToInt16Checked
public short ToInt16Checked();
Converts this number's value to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a 16-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -32768 or greater than 32767.
ToInt16IfExact
public short ToInt16IfExact();
Converts this number's value to a 16-bit signed integer if it can fit in a 16-bit signed integer without rounding to a different numerical value.
Return Value:
This number's value as a 16-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -32768 or greater than 32767.
ToInt16Unchecked
public short ToInt16Unchecked();
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 16-bit signed integer.
Return Value:
This number, converted to a 16-bit signed integer. Returns 0 if this value is infinity or not-a-number.
ToInt32Checked
public int ToInt32Checked();
Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a 32-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -2147483648 or greater than 2147483647.
ToInt32IfExact
public int ToInt32IfExact();
Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.
Return Value:
This number's value as a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -2147483648 or greater than 2147483647.
ToInt32Unchecked
public int ToInt32Unchecked();
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 32-bit signed integer.
Return Value:
This number, converted to a 32-bit signed integer. Returns 0 if this value is infinity or not-a-number.
ToInt64Checked
public long ToInt64Checked();
Converts this number's value to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a 64-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -9223372036854775808 or greater than 9223372036854775807.
ToInt64IfExact
public long ToInt64IfExact();
Converts this number's value to a 64-bit signed integer if it can fit in a 64-bit signed integer without rounding to a different numerical value.
Return Value:
This number's value as a 64-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -9223372036854775808 or greater than 9223372036854775807.
ToInt64Unchecked
public long ToInt64Unchecked();
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 64-bit signed integer.
Return Value:
This number, converted to a 64-bit signed integer. Returns 0 if this value is infinity or not-a-number.
ToSByteChecked
public sbyte ToSByteChecked();
This API is not CLS-compliant.
Converts this number's value to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to an 8-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -128 or greater than 127.
ToSByteIfExact
public sbyte ToSByteIfExact();
This API is not CLS-compliant.
Converts this number's value to an 8-bit signed integer if it can fit in an 8-bit signed integer without rounding to a different numerical value.
Return Value:
This number's value as an 8-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -128 or greater than 127.
ToSByteUnchecked
public sbyte ToSByteUnchecked();
This API is not CLS-compliant.
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as an 8-bit signed integer.
Return Value:
This number, converted to an 8-bit signed integer. Returns 0 if this value is infinity or not-a-number.
ToString
public override string ToString();
Returns the value of this object in text form.
Return Value:
A text string representing the value of this object.
ToUInt16Checked
public ushort ToUInt16Checked();
This API is not CLS-compliant.
Converts this number's value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a 16-bit unsigned integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 65535.
ToUInt16IfExact
public ushort ToUInt16IfExact();
This API is not CLS-compliant.
Converts this number's value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer without rounding to a different numerical value.
Return Value:
This number's value as a 16-bit unsigned integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 65535.
ToUInt16Unchecked
public ushort ToUInt16Unchecked();
This API is not CLS-compliant.
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 16-bit unsigned integer.
Return Value:
This number, converted to a 16-bit unsigned integer. Returns 0 if this value is infinity or not-a-number.
ToUInt32Checked
public uint ToUInt32Checked();
This API is not CLS-compliant.
Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a 32-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 4294967295.
ToUInt32IfExact
public uint ToUInt32IfExact();
This API is not CLS-compliant.
Converts this number's value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.
Return Value:
This number's value as a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 4294967295.
ToUInt32Unchecked
public uint ToUInt32Unchecked();
This API is not CLS-compliant.
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 32-bit signed integer.
Return Value:
This number, converted to a 32-bit signed integer. Returns 0 if this value is infinity or not-a-number.
ToUInt64Checked
public ulong ToUInt64Checked();
This API is not CLS-compliant.
Converts this number's value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number's value, truncated to a 64-bit unsigned integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 18446744073709551615.
ToUInt64IfExact
public ulong ToUInt64IfExact();
This API is not CLS-compliant.
Converts this number's value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer without rounding to a different numerical value.
Return Value:
This number's value as a 64-bit unsigned integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 18446744073709551615.
ToUInt64Unchecked
public ulong ToUInt64Unchecked();
This API is not CLS-compliant.
Converts this number's value to an integer by discarding its fractional part, and returns the least-significant bits of its two's-complement form as a 64-bit unsigned integer.
Return Value:
This number, converted to a 64-bit unsigned integer. Returns 0 if this value is infinity or not-a-number.