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 notanumber or NaN values are considered numbers. Currently, this class can store one of the following kinds of numbers: 64bit signed integers or binary floatingpoint numbers; or arbitraryprecision integers, decimal numbers, binary numbers, or rational numbers.
Member Summary
[Abs()](#Abs)
 Returns the absolute value of this CBOR number.[Add(PeterO.Cbor.CBORNumber)](#Add_PeterO_Cbor_CBORNumber)
 Returns the sum of this number and another number.[CanFitInDouble()](#CanFitInDouble)
 Returns whether this object’s value can be converted to a 64bit floating point number without its value being rounded to another numerical value.[CanFitInInt32()](#CanFitInInt32)
 Returns whether this object’s numerical value is an integer, is (2^31) or greater, and is less than 2^31.[CanFitInInt64()](#CanFitInInt64)
 Returns whether this object’s numerical value is an integer, is (2^63) or greater, and is less than 2^63.[CanFitInSingle()](#CanFitInSingle)
 Returns whether this object’s value can be converted to a 32bit floating point number without its value being rounded to another numerical value.[CanFitInUInt64()](#CanFitInUInt64)
 Returns whether this object’s numerical value is an integer, is 0 or greater, and is less than 2^64.[CanTruncatedIntFitInInt32()](#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()](#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()](#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)](#CompareTo_int)
 Compares this CBOR number with a 32bit signed integer.[CompareTo(long)](#CompareTo_long)
 Compares this CBOR number with a 64bit signed integer.[CompareTo(PeterO.Cbor.CBORNumber)](#CompareTo_PeterO_Cbor_CBORNumber)
 Compares this CBOR number with another.[Divide(PeterO.Cbor.CBORNumber)](#Divide_PeterO_Cbor_CBORNumber)
 Returns the quotient of this number and another number.[FromByte(byte)](#FromByte_byte)
 Converts a byte (from 0 to 255) to an arbitraryprecision decimal number.[FromCBORObject(PeterO.Cbor.CBORObject)](#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)](#FromInt16_short)
 Converts a 16bit signed integer to an arbitraryprecision decimal number.[IsFinite()](#IsFinite)
 Gets a value indicating whether this CBOR object represents a finite number.[IsInfinity()](#IsInfinity)
 Gets a value indicating whether this object represents infinity.[IsInteger()](#IsInteger)
 Gets a value indicating whether this object represents an integer number, that is, a number without a fractional part.[IsNaN()](#IsNaN)
 Gets a value indicating whether this object represents a notanumber value.[IsNegative()](#IsNegative)
 Gets a value indicating whether this object is a negative number.[IsNegativeInfinity()](#IsNegativeInfinity)
 Gets a value indicating whether this object represents negative infinity.[IsPositiveInfinity()](#IsPositiveInfinity)
 Gets a value indicating whether this object represents positive infinity.[IsZero()](#IsZero)
 Gets a value indicating whether this object’s value equals 0.[Kind](#Kind)
 Gets the underlying form of this CBOR number object.[Multiply(PeterO.Cbor.CBORNumber)](#Multiply_PeterO_Cbor_CBORNumber)
 Returns a CBOR number expressing the product of this number and the given number.[Negate()](#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)](#op_GreaterThan)
 Returns whether one object’s value is greater than another’s.[bool operator >=(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)](#op_GreaterThanOrEqual)
 Returns whether one object’s value is at least another’s.[bool operator <(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)](#op_LessThan)
 Returns whether one object’s value is less than another’s.[bool operator <=(PeterO.Cbor.CBORNumber, PeterO.Cbor.CBORNumber)](#op_LessThanOrEqual)
 Returns whether one object’s value is up to another’s.[Remainder(PeterO.Cbor.CBORNumber)](#Remainder_PeterO_Cbor_CBORNumber)
 Returns the remainder when this number is divided by another number.[Sign](#Sign)
 Gets this value’s sign: 1 if nonzero and negative; 1 if nonzero and positive; 0 if zero.[Subtract(PeterO.Cbor.CBORNumber)](#Subtract_PeterO_Cbor_CBORNumber)
 Returns a number that expresses this number minus another.[ToByteChecked()](#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()](#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()](#ToByteUnchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a byte (from 0 to 255).[ToCBORObject()](#ToCBORObject)
 Converts this object’s value to a CBOR object.[ToEDecimal()](#ToEDecimal)
 Converts this object to a decimal number.[ToEFloat()](#ToEFloat)
 Converts this object to an arbitraryprecision binary floating point number.[ToEInteger()](#ToEInteger)
 Converts this object to an arbitraryprecision integer.[ToEIntegerIfExact()](#ToEIntegerIfExact)
 Converts this object to an arbitraryprecision integer if its value is an integer.[ToERational()](#ToERational)
 Converts this object to a rational number.[ToInt16Checked()](#ToInt16Checked)
 Converts this number’s value to a 16bit signed integer if it can fit in a 16bit signed integer after converting it to an integer by discarding its fractional part.[ToInt16IfExact()](#ToInt16IfExact)
 Converts this number’s value to a 16bit signed integer if it can fit in a 16bit signed integer without rounding to a different numerical value.[ToInt16Unchecked()](#ToInt16Unchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 16bit signed integer.[ToInt32Checked()](#ToInt32Checked)
 Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer after converting it to an integer by discarding its fractional part.[ToInt32IfExact()](#ToInt32IfExact)
 Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer without rounding to a different numerical value.[ToInt32Unchecked()](#ToInt32Unchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 32bit signed integer.[ToInt64Checked()](#ToInt64Checked)
 Converts this number’s value to a 64bit signed integer if it can fit in a 64bit signed integer after converting it to an integer by discarding its fractional part.[ToInt64IfExact()](#ToInt64IfExact)
 Converts this number’s value to a 64bit signed integer if it can fit in a 64bit signed integer without rounding to a different numerical value.[ToInt64Unchecked()](#ToInt64Unchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 64bit signed integer.[ToSByteChecked()](#ToSByteChecked)
 Converts this number’s value to an 8bit signed integer if it can fit in an 8bit signed integer after converting it to an integer by discarding its fractional part.[ToSByteIfExact()](#ToSByteIfExact)
 Converts this number’s value to an 8bit signed integer if it can fit in an 8bit signed integer without rounding to a different numerical value.[ToSByteUnchecked()](#ToSByteUnchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as an 8bit signed integer.[ToString()](#ToString)
 Returns the value of this object in text form.[ToUInt16Checked()](#ToUInt16Checked)
 Converts this number’s value to a 16bit unsigned integer if it can fit in a 16bit unsigned integer after converting it to an integer by discarding its fractional part.[ToUInt16IfExact()](#ToUInt16IfExact)
 Converts this number’s value to a 16bit unsigned integer if it can fit in a 16bit unsigned integer without rounding to a different numerical value.[ToUInt16Unchecked()](#ToUInt16Unchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 16bit unsigned integer.[ToUInt32Checked()](#ToUInt32Checked)
 Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer after converting it to an integer by discarding its fractional part.[ToUInt32IfExact()](#ToUInt32IfExact)
 Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer without rounding to a different numerical value.[ToUInt32Unchecked()](#ToUInt32Unchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 32bit signed integer.[ToUInt64Checked()](#ToUInt64Checked)
 Converts this number’s value to a 64bit unsigned integer if it can fit in a 64bit unsigned integer after converting it to an integer by discarding its fractional part.[ToUInt64IfExact()](#ToUInt64IfExact)
 Converts this number’s value to a 64bit unsigned integer if it can fit in a 64bit unsigned integer without rounding to a different numerical value.[ToUInt64Unchecked()](#ToUInt64Unchecked)
 Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 64bit unsigned integer.
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.
public int Sign { get; }
Gets this value’s sign: 1 if nonzero and negative; 1 if nonzero and positive; 0 if zero. Notanumber (NaN) values are positive or negative depending on what sign is stored in their underlying forms.
Returns:
This value’s sign.
public PeterO.Cbor.CBORNumber Abs();
Returns the absolute value of this CBOR number.
Return Value:
This object’s absolute value without its negative sign.
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).
public bool CanFitInDouble();
Returns whether this object’s value can be converted to a 64bit 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 64bit floating point number without its value being rounded to another numerical value, or if this is a notanumber value, even if the value’s diagnostic information can’t fit in a 64bit floating point number; otherwise, false
.
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
.
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
.
public bool CanFitInSingle();
Returns whether this object’s value can be converted to a 32bit 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 32bit floating point number without its value being rounded to another numerical value, or if this is a notanumber value, even if the value’s diagnostic information can’ t fit in a 32bit floating point number; otherwise, false
.
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
.
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
.
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
.
public int CompareTo( int other);
Compares this CBOR number with a 32bit signed integer. In this implementation, the two numbers’ mathematical values are compared. Here, NaN (notanumber) 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.
.
public int CompareTo( long other);
Compares this CBOR number with a 64bit signed integer. In this implementation, the two numbers’ mathematical values are compared. Here, NaN (notanumber) 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.
.
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 (notanumber) 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.
.
public PeterO.Cbor.CBORNumber Divide( PeterO.Cbor.CBORNumber b);
Returns the quotient of this number and another number.
Parameters:
 b: The righthand 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).
public static PeterO.Cbor.CBORNumber FromByte( byte inputByte);
Converts a byte (from 0 to 255) to an arbitraryprecision decimal number.
Parameters:
 inputByte: The number to convert as a byte (from 0 to 255).
Return Value:
This number’s value as an arbitraryprecision decimal number.
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.
public static PeterO.Cbor.CBORNumber FromInt16( short inputInt16);
Converts a 16bit signed integer to an arbitraryprecision decimal number.
Parameters:
 inputInt16: The number to convert as a 16bit signed integer.
Return Value:
This number’s value as an arbitraryprecision decimal number.
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
.
public bool IsInfinity();
Gets a value indicating whether this object represents infinity.
Return Value:
true
if this object represents infinity; otherwise, false
.
public bool IsInteger();
Gets a value indicating whether this object represents an integer number, that is, a number without a fractional part. Infinity and notanumber are not considered integers.
Return Value:
true
if this object represents an integer number, that is, a number without a fractional part; otherwise, false
.
public bool IsNaN();
Gets a value indicating whether this object represents a notanumber value.
Return Value:
true
if this object represents a notanumber value; otherwise, false
.
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
.
public bool IsNegativeInfinity();
Gets a value indicating whether this object represents negative infinity.
Return Value:
true
if this object represents negative infinity; otherwise, false
.
public bool IsPositiveInfinity();
Gets a value indicating whether this object represents positive infinity.
Return Value:
true
if this object represents positive infinity; otherwise, false
.
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
.
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).
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.
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 lefthand side of the comparison.

b: The righthand 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.
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 lefthand side of the comparison.

b: The righthand 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.
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 lefthand side of the comparison.

b: The righthand 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.
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 lefthand side of the comparison.

b: The righthand 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.
public PeterO.Cbor.CBORNumber Remainder( PeterO.Cbor.CBORNumber b);
Returns the remainder when this number is divided by another number.
Parameters:
 b: The righthand 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).
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).
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 notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 255.
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 notanumber, is not an exact integer, or is less than 0 or greater than 255.
public byte ToByteUnchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement 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 notanumber.
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.
public PeterO.Numbers.EDecimal ToEDecimal();
Converts this object to a decimal number.
Return Value:
A decimal number for this object’s value.
public PeterO.Numbers.EFloat ToEFloat();
Converts this object to an arbitraryprecision binary floating point number. See the ToObject overload taking a type for more information.
Return Value:
An arbitraryprecision binary floatingpoint number for this object’s value.
public PeterO.Numbers.EInteger ToEInteger();
Converts this object to an arbitraryprecision integer. See the ToObject overload taking a type for more information.
Return Value:
The closest arbitraryprecision integer to this object.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber.
public PeterO.Numbers.EInteger ToEIntegerIfExact();
Converts this object to an arbitraryprecision integer if its value is an integer.
Return Value:
The arbitraryprecision integer given by object.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber or is not an exact integer.
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.
public short ToInt16Checked();
Converts this number’s value to a 16bit signed integer if it can fit in a 16bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 16bit signed integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 32768 or greater than 32767.
public short ToInt16IfExact();
Converts this number’s value to a 16bit signed integer if it can fit in a 16bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 16bit signed integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 32768 or greater than 32767.
public short ToInt16Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 16bit signed integer.
Return Value:
This number, converted to a 16bit signed integer. Returns 0 if this value is infinity or notanumber.
public int ToInt32Checked();
Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 32bit signed integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 2147483648 or greater than 2147483647.
public int ToInt32IfExact();
Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 32bit signed integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 2147483648 or greater than 2147483647.
public int ToInt32Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 32bit signed integer.
Return Value:
This number, converted to a 32bit signed integer. Returns 0 if this value is infinity or notanumber.
public long ToInt64Checked();
Converts this number’s value to a 64bit signed integer if it can fit in a 64bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 64bit signed integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 9223372036854775808 or greater than 9223372036854775807.
public long ToInt64IfExact();
Converts this number’s value to a 64bit signed integer if it can fit in a 64bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 64bit signed integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 9223372036854775808 or greater than 9223372036854775807.
public long ToInt64Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 64bit signed integer.
Return Value:
This number, converted to a 64bit signed integer. Returns 0 if this value is infinity or notanumber.
public sbyte ToSByteChecked();
This API is not CLScompliant.
Converts this number’s value to an 8bit signed integer if it can fit in an 8bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to an 8bit signed integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 128 or greater than 127.
public sbyte ToSByteIfExact();
This API is not CLScompliant.
Converts this number’s value to an 8bit signed integer if it can fit in an 8bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as an 8bit signed integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 128 or greater than 127.
public sbyte ToSByteUnchecked();
This API is not CLScompliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as an 8bit signed integer.
Return Value:
This number, converted to an 8bit signed integer. Returns 0 if this value is infinity or notanumber.
public override string ToString();
Returns the value of this object in text form.
Return Value:
A text string representing the value of this object.
public ushort ToUInt16Checked();
This API is not CLScompliant.
Converts this number’s value to a 16bit unsigned integer if it can fit in a 16bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 16bit unsigned integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 65535.
public ushort ToUInt16IfExact();
This API is not CLScompliant.
Converts this number’s value to a 16bit unsigned integer if it can fit in a 16bit unsigned integer without rounding to a different numerical value.
Return Value:
This number’s value as a 16bit unsigned integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 0 or greater than 65535.
public ushort ToUInt16Unchecked();
This API is not CLScompliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 16bit unsigned integer.
Return Value:
This number, converted to a 16bit unsigned integer. Returns 0 if this value is infinity or notanumber.
public uint ToUInt32Checked();
This API is not CLScompliant.
Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 32bit signed integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 4294967295.
public uint ToUInt32IfExact();
This API is not CLScompliant.
Converts this number’s value to a 32bit signed integer if it can fit in a 32bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 32bit signed integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 0 or greater than 4294967295.
public uint ToUInt32Unchecked();
This API is not CLScompliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 32bit signed integer.
Return Value:
This number, converted to a 32bit signed integer. Returns 0 if this value is infinity or notanumber.
public ulong ToUInt64Checked();
This API is not CLScompliant.
Converts this number’s value to a 64bit unsigned integer if it can fit in a 64bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 64bit unsigned integer.
Exceptions:
 System.OverflowException: This value is infinity or notanumber, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 18446744073709551615.
public ulong ToUInt64IfExact();
This API is not CLScompliant.
Converts this number’s value to a 64bit unsigned integer if it can fit in a 64bit unsigned integer without rounding to a different numerical value.
Return Value:
This number’s value as a 64bit unsigned integer.
Exceptions:
 System.ArithmeticException: This value is infinity or notanumber, is not an exact integer, or is less than 0 or greater than 18446744073709551615.
public ulong ToUInt64Unchecked();
This API is not CLScompliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the leastsignificant bits of its two’scomplement form as a 64bit unsigned integer.
Return Value:
This number, converted to a 64bit unsigned integer. Returns 0 if this value is infinity or notanumber.