diff --git a/codacy.yml b/.codacy.yml similarity index 86% rename from codacy.yml rename to .codacy.yml index b437e3fd..3064ccc6 100644 --- a/codacy.yml +++ b/.codacy.yml @@ -5,4 +5,5 @@ exclude_paths: - '**/PlayModeTests/**' - '**/ThirdParty/**' - '**/Crypto/MD5.*' + - '**/Snippets/**' \ No newline at end of file diff --git a/.pubnub.yml b/.pubnub.yml index 8ff8dadb..fa8e05bf 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,6 +1,17 @@ --- -version: v9.0.1 +version: v9.1.0 changelog: + - date: 2025-07-08 + version: v9.1.0 + changes: + - type: feature + text: "Added the PubnubUnityUtils.NewUnityPubnub() method to streamline creating Pubnub instances with Unity-specific settings outside of PNManagerBehaviour." + - type: feature + text: "Implemented an in-house CBOR solution for ParseToken() handling to reduce total SDK+dependencies size." + - type: bug + text: "Improved parsing of file download errors to be properly set in operation status ErrorData." + - type: improvement + text: "Updated log type from Error to Warn for TaskCanceledException." - date: 2025-05-30 version: v9.0.1 changes: @@ -779,7 +790,7 @@ sdks: distribution-type: package distribution-repository: git release package-name: PubNub.unitypackage - location: https://github.com/pubnub/unity/releases/download/v9.0.1/PubNub.unitypackage + location: https://github.com/pubnub/unity/releases/download/v9.1.0/PubNub.unitypackage requires: - name: "UnityEditor" @@ -911,7 +922,7 @@ sdks: distribution-type: package distribution-repository: git release package-name: PubNub.unitypackage - location: https://github.com/pubnub/unity/releases/download/v9.0.1/PubNub.unitypackage + location: https://github.com/pubnub/unity/releases/download/v9.1.0/PubNub.unitypackage requires: - name: "UnityEditor" diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.dll b/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.dll deleted file mode 100644 index 5c06bec8..00000000 Binary files a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.dll and /dev/null differ diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.dll.meta b/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.dll.meta deleted file mode 100644 index 241c4736..00000000 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.dll.meta +++ /dev/null @@ -1,75 +0,0 @@ -fileFormatVersion: 2 -guid: abe26334fe762df46893ffc1cf8e4a18 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude WebGL: 0 - Exclude Win: 0 - Exclude Win64: 0 - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 1 - settings: - CPU: AnyCPU - DefaultValueInitialized: true - OS: AnyOS - - first: - Standalone: Linux64 - second: - enabled: 1 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 1 - settings: - CPU: None - - first: - Standalone: Win - second: - enabled: 1 - settings: - CPU: x86 - - first: - Standalone: Win64 - second: - enabled: 1 - settings: - CPU: x86_64 - - first: - WebGL: WebGL - second: - enabled: 1 - settings: {} - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.xml b/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.xml deleted file mode 100644 index 04e7285d..00000000 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.xml +++ /dev/null @@ -1,6997 +0,0 @@ - - - - CBOR - - - - Contains methods useful for reading and writing data, with - a focus on CBOR. - - - Parses a number whose format follows the JSON - specification. The method uses a JSONOptions with all default - properties except for a PreserveNegativeZero property of - false. - A text string to parse as a JSON number. - A CBOR object that represents the parsed number. Returns - positive zero if the number is a zero that starts with a minus sign - (such as "-0" or "-0.0"). Returns null if the parsing fails, - including if the string is null or empty. - - - Parses a number whose format follows the JSON - specification (RFC 8259). The method uses a JSONOptions with all - default properties except for a PreserveNegativeZero property of - false. - A text string to parse as a JSON number. - If true, no decimal points or exponents - are allowed in the string. The default is false. - If true, only positive numbers are - allowed (the leading minus is disallowed). The default is - false. - A CBOR object that represents the parsed number. Returns - positive zero if the number is a zero that starts with a minus sign - (such as "-0" or "-0.0"). Returns null if the parsing fails, - including if the string is null or empty. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A text string representing - a valid JSON number is not allowed to contain white space - characters, including spaces. - - - Parses a number whose format follows the JSON - specification (RFC 8259). - A text string to parse as a JSON number. - If true, no decimal points or exponents - are allowed in the string. The default is false. - If true, the leading minus is disallowed - in the string. The default is false. - If true, returns positive zero - if the number is a zero that starts with a minus sign (such as "-0" - or "-0.0"). Otherwise, returns negative zero in this case. The - default is false. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the string is null or - empty. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A text string representing - a valid JSON number is not allowed to contain white space - characters, including spaces. - - - Parses a number whose format follows the JSON - specification (RFC 8259) and converts that number to a CBOR - object. - A text string to parse as a JSON number. - An object containing options to control how - JSON numbers are decoded to CBOR objects. Can be null, in which - case a JSONOptions object with all default properties is used - instead. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the string is null or - empty. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A text string representing - a valid JSON number is not allowed to contain white space - characters, including spaces. - - - Parses a number whose format follows the JSON - specification (RFC 8259) from a portion of a text string, and - converts that number to a CBOR object. - A text string containing the portion to parse as - a JSON number. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the string is null or - empty. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - The parameter is null. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A text string representing - a valid JSON number is not allowed to contain white space - characters, including spaces. - - - Parses a number whose format follows the JSON - specification (RFC 8259) and converts that number to a CBOR - object. - A text string to parse as a JSON number. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An object containing options to control how - JSON numbers are decoded to CBOR objects. Can be null, in which - case a JSONOptions object with all default properties is used - instead. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the string is null or empty - or is 0 or less. - The parameter is null. - Unsupported conversion - kind. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A text string representing - a valid JSON number is not allowed to contain white space - characters, including spaces. - - - Parses a number from a byte sequence whose format follows - the JSON specification (RFC 8259) and converts that number to a - CBOR object. - A sequence of bytes to parse as a JSON - number. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An object containing options to control how - JSON numbers are decoded to CBOR objects. Can be null, in which - case a JSONOptions object with all default properties is used - instead. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the byte sequence is null - or empty or is 0 or less. - The parameter is null. - Unsupported conversion - kind. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A byte sequence - representing a valid JSON number is not allowed to contain white - space characters, including spaces. - - - Parses a number from a byte sequence whose format follows - the JSON specification (RFC 8259) and converts that number to a - CBOR object. - A sequence of bytes to parse as a JSON - number. - An object containing options to control how - JSON numbers are decoded to CBOR objects. Can be null, in which - case a JSONOptions object with all default properties is used - instead. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the byte sequence is null - or empty. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A byte sequence - representing a valid JSON number is not allowed to contain white - space characters, including spaces. - - - Parses a number whose format follows the JSON - specification (RFC 8259) from a portion of a byte sequence, and - converts that number to a CBOR object. - A sequence of bytes to parse as a JSON - number. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the byte sequence is null - or empty. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - The parameter is null. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A byte sequence - representing a valid JSON number is not allowed to contain white - space characters, including spaces. - - - Parses a number from a byte sequence whose format follows - the JSON specification. The method uses a JSONOptions with all - default properties except for a PreserveNegativeZero property of - false. - A byte sequence to parse as a JSON - number. - A CBOR object that represents the parsed number. Returns - positive zero if the number is a zero that starts with a minus sign - (such as "-0" or "-0.0"). Returns null if the parsing fails, - including if the byte sequence is null or empty. - - - Parses a number from a sequence of char s whose - format follows the JSON specification (RFC 8259) and converts that - number to a CBOR object. - A sequence of char s to parse as a JSON - number. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An object containing options to control how - JSON numbers are decoded to CBOR objects. Can be null, in which - case a JSONOptions object with all default properties is used - instead. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the sequence of char - s is null or empty or is 0 or - less. - The parameter is null. - Unsupported conversion - kind. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A sequence of char - s representing a valid JSON number is not allowed to contain white - space characters, including spaces. - - - Parses a number from a sequence of char s whose - format follows the JSON specification (RFC 8259) and converts that - number to a CBOR object. - A sequence of char s to parse as a JSON - number. - An object containing options to control how - JSON numbers are decoded to CBOR objects. Can be null, in which - case a JSONOptions object with all default properties is used - instead. - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the sequence of char - s is null or empty. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A sequence of char - s representing a valid JSON number is not allowed to contain white - space characters, including spaces. - - - Parses a number whose format follows the JSON - specification (RFC 8259) from a portion of a sequence of - char s, and converts that number to a CBOR object. - A sequence of char s to parse as a JSON - number. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - A CBOR object that represents the parsed number. Returns - null if the parsing fails, including if the sequence of char - s is null or empty. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - The parameter is null. - Roughly speaking, a valid JSON number consists of an - optional minus sign, one or more basic digits (starting with 1 to 9 - unless there is only one digit and that digit is 0), an optional - decimal point (".", full stop) with one or more basic digits, and - an optional letter E or e with an optional plus or minus sign and - one or more basic digits (the exponent). A sequence of char - s representing a valid JSON number is not allowed to contain white - space characters, including spaces. - - - Parses a number from a sequence of char s whose - format follows the JSON specification. The method uses a - JSONOptions with all default properties except for a - PreserveNegativeZero property of false. - A sequence of char s to parse as a JSON - number. - A CBOR object that represents the parsed number. Returns - positive zero if the number is a zero that starts with a minus sign - (such as "-0" or "-0.0"). Returns null if the parsing fails, - including if the sequence of char s is null or - empty. - - - - A class for converting date-time objects to and from tagged - CBOR objects. - In this class's documentation, the "number of seconds since - the start of 1970" is based on the POSIX definition of "seconds - since the Epoch", a definition that does not count leap seconds. - This number of seconds assumes the use of a proleptic Gregorian - calendar, in which the rules regarding the number of days in each - month and which years are leap years are the same for all years as - they were in 1970 (including without regard to time zone - differences or transitions from other calendars to the - Gregorian). - - - A converter object where FromCBORObject accepts CBOR - objects with tag 0 (date/time strings) and tag 1 (number of seconds - since the start of 1970), and ToCBORObject converts date/time - objects (DateTime in DotNet, and Date in Java) to CBOR objects of - tag 0. - - - A converter object where FromCBORObject accepts CBOR - objects with tag 0 (date/time strings) and tag 1 (number of seconds - since the start of 1970), and ToCBORObject converts date/time - objects (DateTime in DotNet, and Date in Java) to CBOR objects of - tag 1. The ToCBORObject conversion is lossless only if the number - of seconds since the start of 1970 can be represented exactly as an - integer in the interval [-(2^64), 2^64 - 1] or as a 64-bit - floating-point number in the IEEE 754r binary64 format; the - conversion is lossy otherwise. The ToCBORObject conversion will - throw an exception if the conversion to binary64 results in - positive infinity, negative infinity, or not-a-number. - - - A converter object where FromCBORObject accepts untagged - CBOR integer or CBOR floating-point objects that give the number of - seconds since the start of 1970, and where ToCBORObject converts - date/time objects (DateTime in DotNet, and Date in Java) to such - untagged CBOR objects. The ToCBORObject conversion is lossless only - if the number of seconds since the start of 1970 can be represented - exactly as an integer in the interval [-(2^64), 2^64 - 1] or as a - 64-bit floating-point number in the IEEE 754r binary64 format; the - conversion is lossy otherwise. The ToCBORObject conversion will - throw an exception if the conversion to binary64 results in - positive infinity, negative infinity, or not-a-number. - - - Conversion type for date-time conversion. - - - FromCBORObject accepts CBOR objects with tag 0 (date/time - strings) and tag 1 (number of seconds since the start of 1970), and - ToCBORObject converts date/time objects to CBOR objects of tag - 0. - - - FromCBORObject accepts objects with tag 0 (date/time - strings) and tag 1 (number of seconds since the start of 1970), and - ToCBORObject converts date/time objects to CBOR objects of tag 1. - The ToCBORObject conversion is lossless only if the number of - seconds since the start of 1970 can be represented exactly as an - integer in the interval [-(2^64), 2^64 - 1] or as a 64-bit - floating-point number in the IEEE 754r binary64 format; the - conversion is lossy otherwise. The ToCBORObject conversion will - throw an exception if the conversion to binary64 results in - positive infinity, negative infinity, or not-a-number. - - - FromCBORObject accepts untagged CBOR integer or CBOR - floating-point objects that give the number of seconds since the - start of 1970, and ToCBORObject converts date/time objects - (DateTime in DotNet, and Date in Java) to such untagged CBOR - objects. The ToCBORObject conversion is lossless only if the number - of seconds since the start of 1970 can be represented exactly as an - integer in the interval [-(2^64), 2^64 - 1] or as a 64-bit - floating-point number in the IEEE 754r binary64 format; the - conversion is lossy otherwise. The ToCBORObject conversion will - throw an exception if the conversion to binary64 results in - positive infinity, negative infinity, or not-a-number. - - - Initializes a new instance of the - class. - - - Gets the conversion type for this date - converter. - The conversion type for this date converter. - - - Initializes a new instance of the - class. - Conversion type giving the rules for - converting dates and times to and from CBOR objects. - - - Converts a CBOR object to a DateTime (in DotNet) or a Date - (in Java). - A CBOR object that specifies a date/time - according to the conversion type used to create this date - converter. - A DateTime or Date that encodes the date/time specified in - the CBOR object. - The parameter is null. - The format of the CBOR - object is not supported, or another error occurred in - conversion. - - - Tries to extract the fields of a date and time in the form - of a CBOR object. - A CBOR object that specifies a date/time - according to the conversion type used to create this date - converter. - An array whose first element will store the - year. The array's length must be 1 or greater. If this function - fails, the first element is set to null. - An array that will store the fields - (other than the year) of the date and time. The array's length must - be 7 or greater. If this function fails, the first seven elements - are set to 0. If this method is successful, the first seven - elements of the array (starting at 0) will be as follows: - - 0 - Month of the year, from 1 (January) through 12 - (December). - 1 - Day of the month, from 1 through 31. - 2 - Hour of the day, from 0 through 23. - 3 - Minute of the hour, from 0 through 59. - 4 - Second of the minute, from 0 through 59. - 5 - Fractional seconds, expressed in nanoseconds. This value - cannot be less than 0 and must be less than 1000*1000*1000. - 6 - Number of minutes to subtract from this date and time to - get global time. This number can be positive or negative, but - cannot be less than -1439 or greater than 1439. For tags 0 and 1, - this value is always 0.. - Either true if the method is successful, or - false otherwise. - The parameter or is null, or - contains fewer elements than required. - - - Converts a date/time in the form of a year, month, and day - to a CBOR object. The hour, minute, and second are treated as - 00:00:00 by this method, and the time offset is treated as 0 by - this method. - The year. - Month of the year, from 1 (January) through 12 - (December). - Day of the month, from 1 through 31. - A CBOR object encoding the given date fields according to - the conversion type used to create this date converter. - An error occurred in - conversion. - - - Converts a date/time in the form of a year, month, day, - hour, minute, and second to a CBOR object. The time offset is - treated as 0 by this method. - The year. - Month of the year, from 1 (January) through 12 - (December). - Day of the month, from 1 through 31. - Hour of the day, from 0 through 23. - Minute of the hour, from 0 through 59. - Second of the minute, from 0 through - 59. - A CBOR object encoding the given date fields according to - the conversion type used to create this date converter. - An error occurred in - conversion. - - - Converts a date/time in the form of a year, month, day, - hour, minute, second, fractional seconds, and time offset to a CBOR - object. - The year. - An array that will store the fields - (other than the year) of the date and time. See the - TryGetDateTimeFields method for information on the "lesserFields" - parameter. - A CBOR object encoding the given date fields according to - the conversion type used to create this date converter. - The parameter is null. - An error occurred in - conversion. - - - Converts a date/time in the form of a year, month, day, - hour, minute, second, fractional seconds, and time offset to a CBOR - object. - The year. - An array that will store the fields - (other than the year) of the date and time. See the - TryGetDateTimeFields method for information on the "lesserFields" - parameter. - A CBOR object encoding the given date fields according to - the conversion type used to create this date converter. - The parameter or is - null. - An error occurred in - conversion. - - - Converts a DateTime (in DotNet) or Date (in Java) to a - CBOR object in a manner specified by this converter's conversion - type. - The parameter is a - DateTime object. - A CBOR object encoding the date/time in the DateTime or - Date according to the conversion type used to create this date - converter. - An error occurred in - conversion. - - - Tries to extract the fields of a date and time in the form - of a CBOR object. - A CBOR object that specifies a date/time - according to the conversion type used to create this date - converter. - Will store the year. If this function fails, the - year is set to null. - An array that will store the fields - (other than the year) of the date and time. The array's length must - be 7 or greater. If this function fails, the first seven elements - are set to 0. For more information, see the (EInteger[], int) - overload of this method. - Either true if the method is successful, or - false otherwise. - - - Specifies options for encoding and decoding CBOR - objects. - - - Default options for CBOR objects. Disallow duplicate keys, - and always encode strings using definite-length encoding. - - - Default options for CBOR objects serialized using the - CTAP2 canonicalization (used in Web Authentication, among other - specifications). Disallow duplicate keys, and always encode strings - using definite-length encoding. - - - Initializes a new instance of the - class with all the - default options. - - - Initializes a new instance of the - class. - A value indicating whether to - always encode strings with a definite-length encoding. - A value indicating whether to - disallow duplicate keys when reading CBOR objects from a data - stream. - - - Initializes a new instance of the - class. - A value indicating whether to - encode strings with a definite-length encoding in certain - cases. - A value indicating whether to - allow duplicate keys when reading CBOR objects from a data - stream. - A value indicating whether CBOR - objects are written out using the CTAP2 canonical CBOR encoding - form, which is useful for implementing Web Authentication. - - - Initializes a new instance of the - class. - A string setting forth the options to - use. This is a semicolon-separated list of options, each of which - has a key and a value separated by an equal sign ("="). Whitespace - and line separators are not allowed to appear between the - semicolons or between the equal signs, nor may the string begin or - end with whitespace. The string can be empty, but cannot be null. - The following is an example of this parameter: - allowduplicatekeys=true;ctap2Canonical=true. The key can be - any one of the following where the letters can be any combination - of basic upper-case and/or basic lower-case letters: - allowduplicatekeys, ctap2canonical, - resolvereferences, useindeflengthstrings, - allowempty, float64, keepkeyorder. Keys - other than these are ignored in this version of the CBOR library. - The key float64 was introduced in version 4.4 of this - library. The key keepkeyorder was introduced in version 4.5 - of this library.(Keys are compared using a basic case-insensitive - comparison, in which two strings are equal if they match after - converting the basic upper-case letters A to Z (U+0041 to U+005A) - in both strings to basic lower-case letters.) If two or more - key/value pairs have equal keys (in a basic case-insensitive - comparison), the value given for the last such key is used. The - four keys just given can have a value of 1, true, - yes, or on (where the letters can be any combination - of basic upper-case and/or basic lower-case letters), which means - true, and any other value meaning false. For example, - allowduplicatekeys=Yes and allowduplicatekeys=1 both - set the AllowDuplicateKeys property to true. In the future, - this class may allow other keys to store other kinds of values, not - just true or false. - The parameter is null. - - - Gets the values of this options object's properties in - text form. - A text string containing the values of this options - object's properties. The format of the string is the same as the - one described in the String constructor for this class. - - - Gets a value indicating whether to resolve references to - sharable objects and sharable strings in the process of decoding a - CBOR object. Enabling this property, however, can cause a security - risk if a decoded CBOR object is then re-encoded. - A value indicating whether to resolve references to sharable - objects and sharable strings. The default is false. - - About sharable objects and references - Sharable objects are marked with tag 28, and references to - those objects are marked with tag 29 (where a reference of 0 means - the first sharable object in the CBOR stream, a reference of 1 - means the second, and so on). Sharable strings (byte strings and - text strings) appear within an enclosing object marked with tag - 256, and references to them are marked with tag 25; in general, a - string is sharable only if storing its reference rather than the - string would save space. - Note that unlike most other tags, these tags generally care - about the relative order in which objects appear in a CBOR stream; - thus they are not interoperable with CBOR implementations that - follow the generic CBOR data model (since they may list map keys in - an unspecified order). Interoperability problems with these tags - can be reduced by not using them to mark keys or values of a map or - to mark objects within those keys or values. - Security Note - When this property is enabled and a decoded CBOR object - contains references to sharable CBOR objects within it, those - references will be replaced with the sharable objects they refer to - (but without making a copy of those objects). However, if shared - references are deeply nested and used multiple times, these - references can result in a CBOR object that is orders of magnitude - bigger than if shared references weren't resolved, and this can - cause a denial of service when the decoded CBOR object is then - serialized (e.g., with EncodeToBytes(), ToString(), - ToJSONString(), or WriteTo ), because object - references are expanded in the process. - For example, the following object in CBOR diagnostic - notation, [28(["xxx", "yyy"]), 28([29(0), 29(0), 29(0)]), - 28([29(1), 29(1)]), 28([29(2), 29(2)]), 28([29(3), 29(3)]), - 28([29(4), 29(4)]), 28([29(5), 29(5)])], expands to a CBOR - object with a serialized size of about 1831 bytes when this - property is enabled, as opposed to about 69 bytes when this - property is disabled. - One way to mitigate security issues with this property is to - limit the maximum supported size a CBORObject can have once - serialized to CBOR or JSON. This can be done by passing a so-called - "limited memory stream" to the WriteTo or WriteJSONTo - methods when serializing the object to JSON or CBOR. A "limited - memory stream" is a Stream (or OutputStream in Java) - that throws an exception if it would write more bytes than a given - maximum size or would seek past that size. (See the documentation - for CBORObject.WriteTo or CBORObject.WriteJSONTo for - example code.) Another mitigation is to check the CBOR object's - type before serializing it, since only arrays and maps can have the - security problem described here, or to check the maximum nesting - depth of a CBOR array or map before serializing - it. - - - Gets a value indicating whether to encode strings with an - indefinite-length encoding under certain circumstances. - A value indicating whether to encode strings with an - indefinite-length encoding under certain circumstances. The default - is false. - - - Gets a value indicating whether to preserve the order in - which a CBOR map's keys appear when decoding a CBOR object, by - using maps created as though by CBORObject.NewOrderedMap. If false, - key order is not guaranteed to be preserved when decoding - CBOR. - A value indicating whether to preserve the order in which a - CBOR map's keys appear when decoding a CBOR object. The default is - false. - - - Gets a value indicating whether decoding a CBOR object - will return null instead of a CBOR object if the stream has - no content or the end of the stream is reached before decoding - begins. Used only when decoding CBOR objects. - A value indicating whether decoding a CBOR object will - return null instead of a CBOR object if the stream has no - content or the end of the stream is reached before decoding begins. - The default is false. - - - Gets a value indicating whether to allow duplicate keys - when reading CBOR objects from a data stream. Used only when - decoding CBOR objects. If this property is true and a CBOR - map has two or more values with the same key, the last value of - that key set forth in the CBOR map is taken. - A value indicating whether to allow duplicate keys when - reading CBOR objects from a data stream. The default is - false. - - - Gets a value indicating whether to encode floating-point - numbers in a CBOR object in their 64-bit encoding form regardless - of whether their value can be encoded without loss in a smaller - form. Used only when encoding CBOR objects. - Gets a value indicating whether to encode floating-point - numbers in a CBOR object in their 64-bit encoding form regardless - of whether their value can be encoded without loss in a smaller - form. Used only when encoding CBOR objects. The default is - false. - - - Gets a value indicating whether CBOR objects: - - When encoding, are written out using the CTAP2 canonical CBOR - encoding form, which is useful for implementing Web Authentication - (WebAuthn). - When decoding, are checked for compliance with the CTAP2 - canonical encoding form. In this form, CBOR tags are - not used, map keys are written out in a canonical order, a maximum - depth of four levels of arrays and/or maps is allowed, duplicate - map keys are not allowed when decoding, and floating-point numbers - are written out in their 64-bit encoding form regardless of whether - their value can be encoded without loss in a smaller form. This - implementation allows CBOR objects whose canonical form exceeds - 1024 bytes, the default maximum size for CBOR objects in that form - according to the FIDO Client-to-Authenticator Protocol 2 - specification. - true if CBOR objects are written out using the CTAP2 - canonical CBOR encoding form; otherwise, false. The default - is false. - - - Exception thrown for errors involving CBOR data. - This library may throw exceptions of this type in certain - cases, notably when errors occur, and may supply messages to those - exceptions (the message can be accessed through the Message - property in.NET or the getMessage() method in Java). These - messages are intended to be read by humans to help diagnose the - error (or other cause of the exception); they are not intended to - be parsed by computer programs, and the exact text of the messages - may change at any time between versions of this - library. - - - Initializes a new instance of the - class. - - - Initializes a new instance of the - class. - The parameter is a - text string. - - - Initializes a new instance of the - class. Uses the given - message and inner exception. - The parameter is a - text string. - The parameter is an Exception object. - - - 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. - - - Specifies the underlying form of this CBOR number - object. - - - A 64-bit signed integer. - - - A 64-bit binary floating-point number. - - - An arbitrary-precision integer. - - - An arbitrary-precision decimal number. - - - An arbitrary-precision binary number. - - - An arbitrary-precision rational number. - - - Converts this object's value to a CBOR object. - A CBOR object that stores this object's value. - - - 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. - This value's sign. - - - 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). - The parameter is a CBOR object representing a - number. - A CBOR number object, or null if the given CBOR object is - null or does not represent a number. - - - Gets the underlying form of this CBOR number - object. - The underlying form of this CBOR number object. - - - 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. - 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. - - - 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. - 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. - - - 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. - 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. - - - 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. - 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. - - - 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. - 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. - - - Gets a value indicating whether this CBOR object - represents a finite number. - true if this CBOR object represents a finite - number; otherwise, false. - - - 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. - true if this object represents an integer number, - that is, a number without a fractional part; otherwise, - false. - - - Gets a value indicating whether this object is a negative - number. - true if this object is a negative number; - otherwise, false. - - - Gets a value indicating whether this object's value equals - 0. - true if this object's value equals 0; otherwise, - false. - - - Converts this object to an arbitrary-precision integer. - See the ToObject overload taking a type for more - information. - The closest arbitrary-precision integer to this - object. - This value is infinity or - not-a-number. - - - Converts this object to an arbitrary-precision integer if - its value is an integer. - The arbitrary-precision integer given by object. - This value is infinity or - not-a-number or is not an exact integer. - - - 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. - This number's value, truncated to a byte (from 0 to - 255). - 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. - - - 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). - This number, converted to a byte (from 0 to 255). Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a byte (from 0 to 255). - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 255. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - decimal number. - The number to convert as a byte (from 0 to - 255). - This number's value as an arbitrary-precision decimal - number. - - - 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. - This number's value, truncated to a 16-bit signed - integer. - 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. - - - 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. - This number, converted to a 16-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -32768 or - greater than 32767. - - - Converts a 16-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 16-bit signed - integer. - This number's value as an arbitrary-precision decimal - number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -2147483648 - or greater than 2147483647. - - - 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. - This number's value, truncated to a 64-bit signed - integer. - 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. - - - 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. - This number, converted to a 64-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than - -9223372036854775808 or greater than - 9223372036854775807. - - - Returns the value of this object in text form. - A text string representing the value of this - object. - - - Returns whether this object's numerical value is an - integer, is -(2^31) or greater, and is less than 2^31. - true if this object's numerical value is an - integer, is -(2^31) or greater, and is less than 2^31; otherwise, - false. - - - Returns whether this object's numerical value is an - integer, is -(2^63) or greater, and is less than 2^63. - true if this object's numerical value is an - integer, is -(2^63) or greater, and is less than 2^63; otherwise, - false. - - - Returns whether this object's numerical value is an - integer, is 0 or greater, and is less than 2^64. - true if this object's numerical value is an - integer, is 0 or greater, and is less than 2^64; otherwise, - false. - - - Gets a value indicating whether this object represents - infinity. - true if this object represents infinity; otherwise, - false. - - - Gets a value indicating whether this object represents - positive infinity. - true if this object represents positive infinity; - otherwise, false. - - - Gets a value indicating whether this object represents - negative infinity. - true if this object represents negative infinity; - otherwise, false. - - - Gets a value indicating whether this object represents a - not-a-number value. - true if this object represents a not-a-number - value; otherwise, false. - - - Converts this object to a decimal number. - A decimal number for this object's value. - - - Converts this object to an arbitrary-precision binary - floating point number. See the ToObject overload taking a type for - more information. - An arbitrary-precision binary floating-point number for - this object's value. - - - Converts this object to a rational number. See the - ToObject overload taking a type for more information. - A rational number for this object's value. - - - Returns the absolute value of this CBOR number. - This object's absolute value without its negative - sign. - - - Returns a CBOR number with the same value as this one but - with the sign reversed. - A CBOR number with the same value as this one but with the - sign reversed. - - - Returns the sum of this number and another - number. - The number to add with this one. - The sum of this number and another number. - The parameter is null. - 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). - - - Returns a number that expresses this number minus - another. - The second operand to the subtraction. - A CBOR number that expresses this number minus the given - number. - The parameter is null. - 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). - - - Returns a CBOR number expressing the product of this - number and the given number. - The second operand to the multiplication - operation. - A number expressing the product of this number and the - given number. - The parameter is null. - 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). - - - Returns the quotient of this number and another - number. - The right-hand side (divisor) to the division - operation. - The quotient of this number and another one. - The parameter is null. - 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). - - - Returns the remainder when this number is divided by - another number. - The right-hand side (dividend) of the remainder - operation. - The remainder when this number is divided by the other - number. - The parameter is null. - 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). - - - 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. - A value to compare with. Can be null. - 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 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.. - - - 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. - A value to compare with. Can be null. - 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 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.. - - - 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. - A value to compare with. Can be null. - 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 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.. - - - Returns whether one object's value is less than - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if the first object's value is less than the - other's; otherwise, false. - The parameter is null. - - - Returns whether one object's value is up to - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is up to another's; - otherwise, false. - The parameter is null. - - - Returns whether one object's value is greater than - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is greater than - another's; otherwise, false. - The parameter is null. - - - Returns whether one object's value is at least - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is at least another's; - otherwise, false. - The parameter is null. - - - 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. - This number's value, truncated to an 8-bit signed - integer. - 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. - - - 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. - This number, converted to an 8-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as an 8-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -128 or - greater than 127. - - - 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. - This number's value, truncated to a 16-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 16-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 65535. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 4294967295. - - - 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. - This number's value, truncated to a 64-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 64-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 18446744073709551615. - - - - Represents an object in Concise Binary Object Representation - (CBOR) and contains methods for reading and writing CBOR data. CBOR - is an Internet Standard and defined in RFC 8949. - - Converting CBOR objects - There are many ways to get a CBOR object, including from - bytes, objects, streams and JSON, as described below. - To and from byte arrays: The - CBORObject.DecodeFromBytes method converts a byte array in CBOR - format to a CBOR object. The EncodeToBytes method converts a CBOR - object to its corresponding byte array in CBOR format. - To and from data streams: The CBORObject.Write methods - write many kinds of objects to a data stream, including numbers, - CBOR objects, strings, and arrays of numbers and strings. The - CBORObject.Read method reads a CBOR object from a data - stream. - To and from other objects: The - CBORObject.FromObject method converts many kinds of objects - to a CBOR object, including numbers, strings, and arrays and maps - of numbers and strings. Methods like AsNumber and AsString convert - a CBOR object to different types of object. The - CBORObject.ToObject method converts a CBOR object to an - object of a given type; for example, a CBOR array to a native - List (or ArrayList in Java), or a CBOR integer to an - int or long. - To and from JSON: This class also doubles as a reader - and writer of JavaScript Object Notation (JSON). The - CBORObject.FromJSONString method converts JSON in text string form - to a CBOR object, and the ToJSONString method converts a CBOR - object to a JSON string. (Note that the conversion from CBOR to - JSON is not always without loss and may make it impossible to - recover the original object when converting the JSON back to CBOR. - See the ToJSONString documentation.) Likewise, ToJSONBytes and - FromJSONBytes work with JSON in the form of byte arrays rather than - text strings. - In addition, the CBORObject.WriteJSON method writes many - kinds of objects as JSON to a data stream, including numbers, CBOR - objects, strings, and arrays of numbers and strings. The - CBORObject.Read method reads a CBOR object from a JSON data - stream. - Comparison Considerations: - Instances of CBORObject should not be compared for equality - using the "==" operator; it's possible to create two CBOR objects - with the same value but not the same reference. (The "==" operator - might only check if each side of the operator is the same - instance.) - This class's natural ordering (under the CompareTo method) is - consistent with the Equals method, meaning that two values that - compare as equal under the CompareTo method are also equal under - the Equals method; this is a change in version 4.0. Two otherwise - equal objects with different tags are not treated as equal by both - CompareTo and Equals. To strip the tags from a CBOR object before - comparing, use the Untag method. - Thread Safety: - Certain CBOR objects are immutable (their values can't be - changed), so they are inherently safe for use by multiple - threads. - CBOR objects that are arrays, maps, and byte strings (whether - or not they are tagged) are mutable, but this class doesn't attempt - to synchronize reads and writes to those objects by multiple - threads, so those objects are not thread safe without such - synchronization. - One kind of CBOR object is called a map, or a list of - key-value pairs. Keys can be any kind of CBOR object, including - numbers, strings, arrays, and maps. However, untagged text strings - (which means GetTags returns an empty array and the Type property, - or "getType()" in Java, returns TextString) are the most suitable - to use as keys; other kinds of CBOR object are much better used as - map values instead, keeping in mind that some of them are not - thread safe without synchronizing reads and writes to them. - To find the type of a CBOR object, call its Type property (or - "getType()" in Java). The return value can be Integer, - FloatingPoint, Boolean, SimpleValue, or TextString for immutable - CBOR objects, and Array, Map, or ByteString for mutable CBOR - objects. - Nesting Depth: - The DecodeFromBytes and Read methods can only read objects - with a limited maximum depth of arrays and maps nested within other - arrays and maps. The code sets this maximum depth to 500 (allowing - more than enough nesting for most purposes), but it's possible that - stack overflows in some runtimes might lower the effective maximum - nesting depth. When the nesting depth goes above 500, the - DecodeFromBytes and Read methods throw a CBORException. - The ReadJSON and FromJSONString methods currently have - nesting depths of 1000. - - - Represents the value false. - - - A not-a-number value. - - - The value negative infinity. - - - Represents the value null. - - - The value positive infinity. - - - Represents the value true. - - - Represents the value undefined. - - - Gets a CBOR object for the number zero. - - - Gets the number of keys in this map, or the number of - items in this array, or 0 if this item is neither an array nor a - map. - The number of keys in this map, or the number of items in - this array, or 0 if this item is neither an array nor a - map. - - - Gets the last defined tag for this CBOR data item, or -1 - if the item is untagged. - The last defined tag for this CBOR data item, or -1 if the - item is untagged. - - - Gets a value indicating whether this value is a CBOR false - value, whether tagged or not. - true if this value is a CBOR false value; otherwise, - false. - - - Gets a value indicating whether this CBOR object - represents a finite number. - true if this CBOR object represents a finite number; - otherwise, false. - - - 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. - true if this object represents an integer number, - that is, a number without a fractional part; otherwise, - false. - - - Gets a value indicating whether this CBOR object is a CBOR - null value, whether tagged or not. - true if this value is a CBOR null value; otherwise, - false. - - - Gets a value indicating whether this data item has at - least one tag. - true if this data item has at least one tag; - otherwise, false. - - - Gets a value indicating whether this value is a CBOR true - value, whether tagged or not. - true if this value is a CBOR true value; otherwise, - false. - - - Gets a value indicating whether this value is a CBOR - undefined value, whether tagged or not. - true if this value is a CBOR undefined value; - otherwise, false. - - - Gets a value indicating whether this object's value equals - 0. - true if this object's value equals 0; otherwise, - false. - - - Gets a collection of the keys of this CBOR object. In - general, the order in which those keys occur is undefined unless - this is a map created using the NewOrderedMap method. - A collection of the keys of this CBOR object. To avoid - potential problems, the calling code should not modify the CBOR map - or the returned collection while iterating over the returned - collection. - This object is not a - map. - - - Gets a value indicating whether this object is a negative - number. - true if this object is a negative number; otherwise, - false. - - - Gets the outermost tag for this CBOR data item, or -1 if - the item is untagged. - The outermost tag for this CBOR data item, or -1 if the item - is untagged. - - - Gets this value's sign: -1 if negative; 1 if positive; 0 - if zero. Throws an exception if this is a not-a-number - value. - This value's sign: -1 if negative; 1 if positive; 0 if - zero. - This object does not - represent a number, or this object is a not-a-number (NaN) - value. - - - Gets the simple value ID of this CBOR object, or -1 if the - object is not a simple value. In this method, objects with a CBOR - type of Boolean or SimpleValue are simple values, whether they are - tagged or not. - The simple value ID of this object if it's a simple value, - or -1 if this object is not a simple value. - - - Gets a value indicating whether this CBOR object stores a - number (including infinity or a not-a-number or NaN value). - Currently, this is true if this item is untagged and has a CBORType - of Integer or FloatingPoint, or if this item has only one tag and - that tag is 2, 3, 4, 5, 30, 264, 265, 268, 269, or 270 with the - right data type. - A value indicating whether this CBOR object stores a - number. - - - Gets the general data type of this CBOR object. This - method disregards the tags this object has, if any. - The general data type of this CBOR object. - - - Gets a collection of the key/value pairs stored in this - CBOR object, if it's a map. Returns one entry for each key/value - pair in the map. In general, the order in which those entries occur - is undefined unless this is a map created using the NewOrderedMap - method. - A collection of the key/value pairs stored in this CBOR map, - as a read-only view of those pairs. To avoid potential problems, - the calling code should not modify the CBOR map while iterating - over the returned collection. - This object is not a - map. - - - Gets a collection of the values of this CBOR object, if - it's a map or an array. If this object is a map, returns one value - for each key in the map; in general, the order in which those keys - occur is undefined unless this is a map created using the - NewOrderedMap method. If this is an array, returns all the values - of the array in the order they are listed. (This method can't be - used to get the bytes in a CBOR byte string; for that, use the - GetByteString method instead.). - A collection of the values of this CBOR map or array. To - avoid potential problems, the calling code should not modify the - CBOR map or array or the returned collection while iterating over - the returned collection. - This object is not a - map or an array. - - - Gets the value of a CBOR object by integer index in this - array or by integer key in this map. - Index starting at 0 of the element, or the - integer key to this map. (If this is a map, the given index can be - any 32-bit signed integer, even a negative one.). - The CBOR object referred to by index or key in this array - or map. If this is a CBOR map, returns null (not - CBORObject.Null ) if an item with the given key doesn't - exist (but this behavior may change to throwing an exception in - version 5.0 or later). - This object is not an - array or map. - This object is an array and the - index is less than 0 or at least the size of the array. - The parameter "value" is - null (as opposed to CBORObject.Null). - - - Gets the value of a CBOR object by integer index in this - array or by CBOR object key in this map, or a default value if that - value is not found. - An arbitrary object. If this is a CBOR map, this - parameter is converted to a CBOR object serving as the key to the - map or index to the array, and can be null. If this is a CBOR - array, the key must be an integer 0 or greater and less than the - size of the array, and may be any object convertible to a CBOR - integer. - A value to return if an item with the - given key doesn't exist, or if the CBOR object is an array and the - key is not an integer 0 or greater and less than the size of the - array. - The CBOR object referred to by index or key in this array - or map. If this is a CBOR map, returns null (not - CBORObject.Null ) if an item with the given key doesn't - exist. - - - Gets the value of a CBOR object by integer index in this - array or by CBOR object key in this map. - A CBOR object serving as the key to the map or - index to the array. If this is a CBOR array, the key must be an - integer 0 or greater and less than the size of the array. - The CBOR object referred to by index or key in this array - or map. If this is a CBOR map, returns null (not - CBORObject.Null ) if an item with the given key doesn't - exist. - The key is null (as opposed - to CBORObject.Null); or the set method is called and the value is - null. - This CBOR object is an array - and the key is not an integer 0 or greater and less than the size - of the array. - This object is not a - map or an array. - - - Gets the value of a CBOR object in this map, using a - string as the key. - A key that points to the desired value. - The CBOR object referred to by key in this map. Returns - null if an item with the given key doesn't exist. - The key is - null. - This object is not a - map. - - - Finds the sum of two CBOR numbers. - The parameter is a - CBOR object. - The parameter is a - CBOR object. - A CBOR object. - Either or both operands are not - numbers (as opposed to Not-a-Number, NaN). - The parameter or is null. - - - - Generates a CBOR object from an array of CBOR-encoded - bytes. - A byte array in which a single CBOR object is - encoded. - A CBOR object decoded from the given byte array. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is - empty. - The parameter is null. - - - - Generates a sequence of CBOR objects from an array of - CBOR-encoded bytes. - A byte array in which any number of CBOR objects - (including zero) are encoded, one after the other. Can be empty, - but cannot be null. - An array of CBOR objects decoded from the given byte - array. Returns an empty array if is - empty. - There was an error in - reading or parsing the data. This includes cases where the last - CBOR object in the data was read only partly. - The parameter is null. - - - - Generates a sequence of CBOR objects from an array of - CBOR-encoded bytes. - A byte array in which any number of CBOR objects - (including zero) are encoded, one after the other. Can be empty, - but cannot be null. - Specifies options to control how the CBOR - object is decoded. See - for more information. - In this method, the AllowEmpty property is treated as always set - regardless of that value as specified in this parameter. - An array of CBOR objects decoded from the given byte - array. Returns an empty array if is - empty. - There was an error in - reading or parsing the data. This includes cases where the last - CBOR object in the data was read only partly. - The parameter is null, or the parameter - is null. - - - Generates a list of CBOR objects from an array of bytes in - JavaScript Object Notation (JSON) text sequence format (RFC 7464). - The byte array must be in UTF-8 encoding and may not begin with a - byte-order mark (U+FEFF). - A byte array in which a JSON text sequence is - encoded. - A list of CBOR objects read from the JSON sequence. - Objects that could not be parsed are replaced with null (as - opposed to CBORObject.Null ) in the given list. - The parameter is null. - The byte array is not - empty and does not begin with a record separator byte (0x1e), or an - I/O error occurred. - Generally, each JSON text in a JSON text sequence is - written as follows: Write a record separator byte (0x1e), then - write the JSON text in UTF-8 (without a byte order mark, U+FEFF), - then write the line feed byte (0x0a). RFC 7464, however, uses a - more liberal syntax for parsing JSON text sequences. - - - Converts this object to a byte array in JavaScript Object - Notation (JSON) format. The JSON text will be written out in UTF-8 - encoding, without a byte order mark, to the byte array. See the - overload to ToJSONString taking a JSONOptions argument for further - information. - A byte array containing the converted in JSON - format. - - - Converts this object to a byte array in JavaScript Object - Notation (JSON) format. The JSON text will be written out in UTF-8 - encoding, without a byte order mark, to the byte array. See the - overload to ToJSONString taking a JSONOptions argument for further - information. - Specifies options to control writing the - CBOR object to JSON. - A byte array containing the converted object in JSON - format. - The parameter is null. - - - Generates a list of CBOR objects from an array of bytes in - JavaScript Object Notation (JSON) text sequence format (RFC 7464), - using the specified options to control the decoding process. The - byte array must be in UTF-8 encoding and may not begin with a - byte-order mark (U+FEFF). - A byte array in which a JSON text sequence is - encoded. - Specifies options to control the JSON - decoding process. - A list of CBOR objects read from the JSON sequence. - Objects that could not be parsed are replaced with null (as - opposed to CBORObject.Null ) in the given list. - The parameter is null. - The byte array is not - empty and does not begin with a record separator byte (0x1e), or an - I/O error occurred. - Generally, each JSON text in a JSON text sequence is - written as follows: Write a record separator byte (0x1e), then - write the JSON text in UTF-8 (without a byte order mark, U+FEFF), - then write the line feed byte (0x0a). RFC 7464, however, uses a - more liberal syntax for parsing JSON text sequences. - - - Generates a CBOR object from an array of CBOR-encoded - bytes, using the given CBOREncodeOptions - object to control - the decoding process. - A byte array in which a single CBOR object is - encoded. - Specifies options to control how the CBOR - object is decoded. See - for more information. - A CBOR object decoded from the given byte array. Returns - null (as opposed to CBORObject.Null) if is - empty and the AllowEmpty property is set on the given options - object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. - The parameter is null, or the parameter - is null. - - The following example (originally written in C# for the.NET - version) implements a method that decodes a text string from a CBOR - byte array. It's successful only if the CBOR object contains an - untagged text string. - private static String DecodeTextString(byte[] bytes) { if (bytes == - null) { throw new ArgumentNullException(nameof(mapObj));} - if - (bytes.Length == 0 || bytes[0]<0x60 || bytes[0]>0x7f) {throw new - CBORException();} return CBORObject.DecodeFromBytes(bytes, - CBOREncodeOptions.Default).AsString(); } - . - - - - Divides a CBORObject object by the value of a CBORObject - object. - The parameter is a - CBOR object. - The parameter is a - CBOR object. - The quotient of the two objects. - The parameter or is null. - - - - Generates a CBOR object from a text string in JavaScript - Object Notation (JSON) format. - If a JSON object has duplicate keys, a CBORException is - thrown. This is a change in version 4.0. - Note that if a CBOR object is converted to JSON with - ToJSONString, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A text string in JSON format. The entire string - must contain a single JSON object and not multiple objects. The - string may not begin with a byte-order mark (U+FEFF). - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - A CBOR object. - The parameter is null. - The string is not in - JSON format. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - Generates a CBOR object from a text string in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. - Note that if a CBOR object is converted to JSON with - ToJSONString, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A text string in JSON format. The entire string - must contain a single JSON object and not multiple objects. The - string may not begin with a byte-order mark (U+FEFF). - Specifies options to control the JSON - decoding process. - A CBOR object containing the JSON data decoded. - The parameter or is null. - The string is not in - JSON format. - - - - Generates a CBOR object from a text string in JavaScript - Object Notation (JSON) format. - If a JSON object has duplicate keys, a CBORException is - thrown. This is a change in version 4.0. - Note that if a CBOR object is converted to JSON with - ToJSONString, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A text string in JSON format. The entire string - must contain a single JSON object and not multiple objects. The - string may not begin with a byte-order mark (U+FEFF). - A CBOR object. - The parameter is null. - The string is not in - JSON format. - - - Generates a CBOR object from a text string in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. - Note that if a CBOR object is converted to JSON with - ToJSONString, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A text string in JSON format. The entire string - must contain a single JSON object and not multiple objects. The - string may not begin with a byte-order mark (U+FEFF). - Specifies options to control the decoding - process. This method uses only the AllowDuplicateKeys property of - this object. - A CBOR object containing the JSON data decoded. - The parameter or is null. - The string is not in - JSON format. - - - Generates a CBOR object from a text string in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. - Note that if a CBOR object is converted to JSON with - ToJSONString, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - The parameter is a text - string. - An index, starting at 0, showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - The parameter is a Cbor.JSONOptions object. - A CBOR object containing the JSON data decoded. - The parameter or is null. - The string is not in - JSON format. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - Converts this CBOR object to an object of an arbitrary - type. See the documentation for the overload of this method taking - a CBORTypeMapper parameter for more information. This method - doesn't use a CBORTypeMapper parameter to restrict which data types - are eligible for Plain-Old-Data serialization. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: - For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method (such as int - or - String - ) or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - The converted object. - The given type - , or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter is null. - - Java offers no easy way to express a generic type, at least - none as easy as C#'s typeof - operator. The following example, - written in Java, is a way to specify that the return value will be - an ArrayList of String objects. - Type arrayListString = new ParameterizedType() { public Type[] - getActualTypeArguments() { /* Contains one type parameter, - String*/ - return new Type[] { String.class }; } - public Type getRawType() { /* Raw type is - ArrayList */ return ArrayList.class; } - public Type getOwnerType() { - return null; } }; - ArrayList<String> array = (ArrayList<String>) - cborArray.ToObject(arrayListString); - By comparison, the C# version is much shorter. - var array = (List<String>)cborArray.ToObject( - typeof(List<String>)); - . - - - - Converts this CBOR object to an object of an arbitrary - type. See the documentation for the overload of this method taking - a CBORTypeMapper and PODOptions parameters parameters for more - information. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method (such as int or - String ) or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. - The converted object. - The given type - , or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter is null. - - - Converts this CBOR object to an object of an arbitrary - type. See the documentation for the overload of this method taking - a CBORTypeMapper and PODOptions parameters for more information. - This method (without a CBORTypeMapper parameter) allows all data - types not otherwise handled to be eligible for Plain-Old-Data - serialization. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method (such as int or - String ) or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - Specifies options for controlling - deserialization of CBOR objects. - The converted object. - The given type , or this object's CBOR type, is not - supported. - The parameter is null. - The given object's - nesting is too deep, or another error occurred when serializing the - object. - - - Converts this CBOR object to an object of an - arbitrary type. The following cases are checked in the logical - order given (rather than the strict order in which they are - implemented by this library): - If the type is - CBORObject - , return this object. - If the given - object is CBORObject.Null - (with or without tags), returns - null - . - If the object is of a type corresponding - to a type converter mentioned in the - parameter, that converter will be used to convert the CBOR object - to an object of the given type. Type converters can be used to - override the default conversion behavior of almost any - object. - If the type is object - , return this - object. - If the type is char - , converts - single-character CBOR text strings and CBOR integers from 0 through - 65535 to a char - object and returns that char - object. - If the type is bool - ( boolean - in - Java), returns the result of AsBoolean. - If the type is - short - , returns this number as a 16-bit signed integer after - converting its value to an integer by discarding its fractional - part, and throws an exception if this object's value is infinity or - a not-a-number value, or does not represent a number (currently - InvalidOperationException, but may change in the next major - version), or if the value, once converted to an integer by - discarding its fractional part, is less than -32768 or greater than - 32767 (currently OverflowException, but may change in the next - major version). - If the type is long - , returns - this number as a 64-bit signed integer after converting its value - to an integer by discarding its fractional part, and throws an - exception if this object's value is infinity or a not-a-number - value, or does not represent a number (currently - InvalidOperationException, but may change in the next major - version), or if the value, once converted to an integer by - discarding its fractional part, is less than -2^63 or greater than - 2^63-1 (currently OverflowException, but may change in the next - major version). - If the type is short - , the same - rules as for long - are used, but the range is from -32768 - through 32767 and the return type is short - . - If - the type is byte - , the same rules as for long - are - used, but the range is from 0 through 255 and the return type is - byte - . - If the type is sbyte - , the same - rules as for long - are used, but the range is from -128 - through 127 and the return type is sbyte - . - If - the type is ushort - , the same rules as for long - are - used, but the range is from 0 through 65535 and the return type is - ushort - . - If the type is uint - , the same - rules as for long - are used, but the range is from 0 through - 2^31-1 and the return type is uint - . - If the - type is ulong - , the same rules as for long - are used, - but the range is from 0 through 2^63-1 and the return type is - ulong - . - If the type is int - or a - primitive floating-point type ( float - , double - , as - well as decimal - in.NET), returns the result of the - corresponding As* method. - If the type is String - , returns the result of AsString. - If the type is - EFloat - , EDecimal - , EInteger - , or - ERational - in the PeterO.Numbers - - library (in .NET) or the com.github.peteroupc/numbers - - artifact (in Java), or if the type is BigInteger - or - BigDecimal - in the Java version, converts the given object to - a number of the corresponding type and throws an exception - (currently InvalidOperationException) if the object does not - represent a number (for this purpose, infinity and not-a-number - values, but not CBORObject.Null - , are considered numbers). - Currently, this is equivalent to the result of AsEFloat() - , - AsEDecimal() - , AsEInteger - , or AsERational() - , - respectively, but may change slightly in the next major version. - Note that in the case of EFloat - , if this object represents - a decimal number with a fractional part, the conversion may lose - information depending on the number, and if the object is a - rational number with a nonterminating binary expansion, the number - returned is a binary floating-point number rounded to a high but - limited precision. In the case of EDecimal - , if this object - expresses a rational number with a nonterminating decimal - expansion, returns a decimal number rounded to 34 digits of - precision. In the case of EInteger - , if this CBOR object - expresses a floating-point number, it is converted to an integer by - discarding its fractional part, and if this CBOR object expresses a - rational number, it is converted to an integer by dividing the - numerator by the denominator and discarding the fractional part of - the result, and this method throws an exception (currently - OverflowException, but may change in the next major version) if - this object expresses infinity or a not-a-number value. - In the.NET version, if the type is a nullable (e.g., - Nullable<int> - or int? - , returns null - if - this CBOR object is null, or this object's value converted to the - nullable's underlying type, e.g., int - . - If the - type is an enumeration ( Enum - ) type and this CBOR object is - a text string or an integer, returns the appropriate enumerated - constant. (For example, if MyEnum - includes an entry for - MyValue - , this method will return MyEnum.MyValue - if - the CBOR object represents "MyValue" - or the underlying value - for MyEnum.MyValue - .) Note: - If an integer is - converted to a.NET Enum constant, and that integer is shared by - more than one constant of the same type, it is undefined which - constant from among them is returned. (For example, if - MyEnum.Zero=0 - and MyEnum.Null=0 - , converting 0 to - MyEnum - may return either MyEnum.Zero - or - MyEnum.Null - .) As a result, .NET Enum types with constants - that share an underlying value should not be passed to this - method. - If the type is byte[] - (a - one-dimensional byte array) and this CBOR object is a byte string, - returns a byte array which this CBOR byte string's data will be - copied to. (This method can't be used to encode CBOR data to a byte - array; for that, use the EncodeToBytes method instead.) - If the type is a one-dimensional or multidimensional array - type and this CBOR object is an array, returns an array containing - the items in this CBOR object. - If the type is List, - ReadOnlyCollection or the generic or non-generic IList, - ICollection, IEnumerable, IReadOnlyCollection, or IReadOnlyList (or - ArrayList, List, Collection, or Iterable in Java), and if this CBOR - object is an array, returns an object conforming to the type, - class, or interface passed to this method, where the object will - contain all items in this CBOR array. - If the type is - Dictionary, ReadOnlyDictionary or the generic or non-generic - IDictionary or IReadOnlyDictionary (or HashMap or Map in Java), and - if this CBOR object is a map, returns an object conforming to the - type, class, or interface passed to this method, where the object - will contain all keys and values in this CBOR map. - If - the type is an enumeration constant ("enum"), and this CBOR object - is an integer or text string, returns the enumeration constant with - the given number or name, respectively. (Enumeration constants made - up of multiple enumeration constants, as allowed by .NET, can only - be matched by number this way.) - If the type is - DateTime - (or Date - in Java) , returns a date/time - object if the CBOR object's outermost tag is 0 or 1. For tag 1, - this method treats the CBOR object as a number of seconds since the - start of 1970, which is based on the POSIX definition of "seconds - since the Epoch", a definition that does not count leap seconds. In - this method, this number of seconds assumes the use of a proleptic - Gregorian calendar, in which the rules regarding the number of days - in each month and which years are leap years are the same for all - years as they were in 1970 (including without regard to time zone - differences or transitions from other calendars to the Gregorian). - The string format used in tag 0 supports only years up to 4 decimal - digits long. For tag 1, CBOR objects that express infinity or - not-a-number (NaN) are treated as invalid by this method. This - default behavior for DateTime - and Date - can be changed - by passing a suitable CBORTypeMapper to this method, such as a - CBORTypeMapper that registers a CBORDateConverter for - DateTime - or Date - objects. See the examples. - If the type is Uri - (or URI - in Java), returns a - URI object if possible. - If the type is Guid - (or - UUID - in Java), returns a UUID object if possible. - Plain-Old-Data deserialization: If the object is a type not - specially handled above, the type includes a zero-parameter - constructor (default or not), this CBOR object is a CBOR map, and - the "mapper" parameter (if any) allows this type to be eligible for - Plain-Old-Data deserialization, then this method checks the given - type for eligible setters as follows: - (*) In the .NET - version, eligible setters are the public, nonstatic setters of - properties with a public, nonstatic getter. Eligible setters also - include public, nonstatic, non- const - , non- readonly - fields. If a class has two properties and/or fields of the form "X" - and "IsX", where "X" is any name, or has multiple properties and/or - fields with the same name, those properties and fields are - ignored. - (*) In the Java version, eligible setters are - public, nonstatic methods starting with "set" followed by a - character other than a basic digit or lower-case letter, that is, - other than "a" to "z" or "0" to "9", that take one parameter. The - class containing an eligible setter must have a public, nonstatic - method with the same name, but starting with "get" or "is" rather - than "set", that takes no parameters and does not return void. (For - example, if a class has "public setValue(String)" and "public - getValue()", "setValue" is an eligible setter. However, - "setValue()" and "setValue(String, int)" are not eligible setters.) - In addition, public, nonstatic, nonfinal fields are also eligible - setters. If a class has two or more otherwise eligible setters - (methods and/or fields) with the same name, but different parameter - type, they are not eligible setters. - Then, the method - creates an object of the given type and invokes each eligible - setter with the corresponding value in the CBOR map, if any. Key - names in the map are matched to eligible setters according to the - rules described in the - documentation. Note that for security reasons, certain types are - not supported even if they contain eligible setters. For the Java - version, the object creation may fail in the case of a nested - nonstatic class. - - - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: - For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method, such as int - or - String - , or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. Can be - null. - Specifies options for controlling - deserialization of CBOR objects. - The converted object. - The given type - , or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter or is null. - - The following example (originally written in C# for the - DotNet version) uses a CBORTypeMapper to change how CBOR objects - are converted to DateTime objects. In this case, the ToObject - method assumes the CBOR object is an untagged number giving the - number of seconds since the start of 1970. - var conv = new CBORTypeMapper().AddConverter(typeof(DateTime), - CBORDateConverter.UntaggedNumber); - var obj = CBORObject.FromObject().ToObject<DateTime>(conv); - Java offers no easy way to express a generic type, at least - none as easy as C#'s typeof - operator. The following example, - written in Java, is a way to specify that the return value will be - an ArrayList of String objects. - Type arrayListString = new ParameterizedType() { public Type[] - getActualTypeArguments() { /* Contains one type parameter, - String*/ - return new Type[] { String.class }; } - public Type getRawType() { /* Raw type is - ArrayList */ return ArrayList.class; } public Type getOwnerType() { - return null; } }; ArrayList<String> array = - (ArrayList<String>) cborArray.ToObject(arrayListString); - By comparison, the C# version is much shorter. - var array = (List<String>)cborArray.ToObject( - typeof(List<String>)); - . - - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes, using the given CBOREncodeOptions object - to control the decoding process. It is equivalent to - DecodeFromBytes followed by ToObject. See the documentation for - those methods for more information. - A byte array in which a single CBOR object is - encoded. - Specifies options to control how the CBOR object - is decoded. See - for more - information. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method, such as int or - String, or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. Can be - null. - Specifies options for controlling deserialization - of CBOR objects. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type , or this object's CBOR - type, is not supported, or the given object's nesting is too deep, - or another error occurred when serializing the object. - The parameter is null, or the parameter is - null, or the parameter or is null. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes, using the given CBOREncodeOptions object - to control the decoding process. It is equivalent to - DecodeFromBytes followed by ToObject. See the documentation for - those methods for more information. - A byte array in which a single CBOR object is - encoded. - Specifies options to control how the CBOR object - is decoded. See - for more - information. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method, such as int or - String, or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type , or this object's CBOR - type, is not supported, or the given object's nesting is too deep, - or another error occurred when serializing the object. - The parameter is null, or the parameter is - null, or the parameter is null. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes. It is equivalent to DecodeFromBytes followed by - ToObject. See the documentation for those methods for more - information. - A byte array in which a single CBOR object is - encoded. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method, such as int or - String, or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. Can be - null. - Specifies options for controlling deserialization - of CBOR objects. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type , or this object's CBOR - type, is not supported, or the given object's nesting is too deep, - or another error occurred when serializing the object. - The parameter is null, or the parameter or - is null. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes. It is equivalent to DecodeFromBytes followed by - ToObject. See the documentation for those methods for more - information. - A byte array in which a single CBOR object is - encoded. - The type, class, or interface that this method's - return value will belong to. To express a generic type in Java, see - the example. Note: For security reasons, an application - should not base this parameter on user input or other externally - supplied data. Whenever possible, this parameter should be either a - type specially handled by this method, such as int or - String, or a plain-old-data type (POCO or POJO type) within - the control of the application. If the plain-old-data type - references other data types, those types should likewise meet - either criterion above. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type , or this object's CBOR - type, is not supported, or the given object's nesting is too deep, - or another error occurred when serializing the object. - The parameter is null, or the parameter is - null. - - - Generates a CBOR object from a 64-bit signed - integer. - The parameter is a - 64-bit signed integer. - A CBOR object. - - - Generates a CBOR object from a CBOR object. - The parameter is a - CBOR object. - Same as , or "CBORObject.Null" is - is null. - - - Calculates the number of bytes this CBOR object takes when - serialized as a byte array using the EncodeToBytes() method. - This calculation assumes that integers, lengths of maps and arrays, - lengths of text and byte strings, and tag numbers are encoded in - their shortest form; that floating-point numbers are encoded in - their shortest value-preserving form; and that no indefinite-length - encodings are used. - The number of bytes this CBOR object takes when serialized - as a byte array using the EncodeToBytes() method. - The CBOR object has an - extremely deep level of nesting, including if the CBOR object is or - has an array or map that includes itself. - - - Generates a CBOR object from an arbitrary-precision - integer. The CBOR object is generated as follows: - - If the number is null, returns CBORObject.Null. - Otherwise, if the number is greater than or equal to -(2^64) - and less than 2^64, the CBOR object will have the object type - Integer and the appropriate value. - Otherwise, the CBOR object will have tag 2 (zero or positive) - or 3 (negative) and the appropriate value. - An arbitrary-precision integer. Can be - null. - The given number encoded as a CBOR object. Returns - CBORObject.Null if is - null. - - - Generates a CBOR object from an arbitrary-precision binary - floating-point number. The CBOR object is generated as follows - (this is a change in version 4.0): - - If the number is null, returns CBORObject.Null. - Otherwise, if the number expresses infinity, not-a-number, or - negative zero, the CBOR object will have tag 269 and the - appropriate format. - Otherwise, if the number's exponent is at least 2^64 or less - than -(2^64), the CBOR object will have tag 265 and the appropriate - format. - Otherwise, the CBOR object will have tag 5 and the - appropriate format. - An arbitrary-precision binary floating-point - number. Can be null. - The given number encoded as a CBOR object. Returns - CBORObject.Null if is null. - - - Generates a CBOR object from an arbitrary-precision - rational number. The CBOR object is generated as follows (this is a - change in version 4.0): - - If the number is null, returns CBORObject.Null. - Otherwise, if the number expresses infinity, not-a-number, or - negative zero, the CBOR object will have tag 270 and the - appropriate format. - Otherwise, the CBOR object will have tag 30 and the - appropriate format. - An arbitrary-precision rational number. Can - be null. - The given number encoded as a CBOR object. Returns - CBORObject.Null if is null. - - - Generates a CBOR object from a decimal number. The CBOR - object is generated as follows (this is a change in version 4.0): - - If the number is null, returns CBORObject.Null. - Otherwise, if the number expresses infinity, not-a-number, or - negative zero, the CBOR object will have tag 268 and the - appropriate format. - If the number's exponent is at least 2^64 or less than - -(2^64), the CBOR object will have tag 264 and the appropriate - format. - Otherwise, the CBOR object will have tag 4 and the - appropriate format. - An arbitrary-precision decimal number. Can - be null. - The given number encoded as a CBOR object. Returns - CBORObject.Null if is null. - - - Generates a CBOR object from a text string. - A text string value. Can be null. - A CBOR object representing the string, or CBORObject.Null - if stringValue is null. - The string contains an unpaired - surrogate code point. - - - Generates a CBOR object from a 32-bit signed - integer. - The parameter is a - 32-bit signed integer. - A CBOR object. - - - Generates a CBOR object from a 16-bit signed - integer. - The parameter is a - 16-bit signed integer. - A CBOR object generated from the given integer. - - - Returns the CBOR true value or false value, depending on - "value". - Either true or false. - CBORObject.True if value is true; otherwise - CBORObject.False. - - - Generates a CBOR object from a byte (0 to 255). - The parameter is a - byte (from 0 to 255). - A CBOR object generated from the given integer. - - - Generates a CBOR object from a 32-bit floating-point - number. The input value can be a not-a-number (NaN) value (such as - Single.NaN in DotNet or Float.NaN in Java); however, NaN - values have multiple forms that are equivalent for many - applications' purposes, and Single.NaN / Float.NaN is - only one of these equivalent forms. In fact, - CBORObject.FromObject(Single.NaN) or - CBORObject.FromObject(Float.NaN) could produce a - CBOR-encoded object that differs between DotNet and Java, because - Single.NaN / Float.NaN may have a different form in - DotNet and Java (for example, the NaN value's sign may be negative - in DotNet, but positive in Java). - The parameter is a - 32-bit floating-point number. - A CBOR object generated from the given number. - - - Generates a CBOR object from a 64-bit floating-point - number. The input value can be a not-a-number (NaN) value (such as - Double.NaN ); however, NaN values have multiple forms that - are equivalent for many applications' purposes, and - Double.NaN is only one of these equivalent forms. In fact, - CBORObject.FromObject(Double.NaN) could produce a - CBOR-encoded object that differs between DotNet and Java, because - Double.NaN may have a different form in DotNet and Java (for - example, the NaN value's sign may be negative in DotNet, but - positive in Java). - The parameter is a - 64-bit floating-point number. - A CBOR object generated from the given number. - - - Generates a CBOR object from an array of 8-bit bytes; the - byte array is copied to a new byte array in this process. (This - method can't be used to decode CBOR data from a byte array; for - that, use the DecodeFromBytes method instead.). - An array of 8-bit bytes; can be null. - A CBOR object where each element of the given byte array - is copied to a new array, or CBORObject.Null if the value is - null. - - - Generates a CBOR object from an array of CBOR - objects. - An array of CBOR objects. - A CBOR object where each element of the given array is - copied to a new array, or CBORObject.Null if the value is - null. - - - Generates a CBOR object from an array of 32-bit - integers. - An array of 32-bit integers. - A CBOR array object where each element of the given array - is copied to a new array, or CBORObject.Null if the value is - null. - - - Generates a CBOR object from an array of 64-bit - integers. - An array of 64-bit integers. - A CBOR array object where each element of the given array - is copied to a new array, or CBORObject.Null if the value is - null. - - - Generates a CBORObject from an arbitrary object. See the - overload of this method that takes CBORTypeMapper and PODOptions - arguments. - The parameter is an - arbitrary object, which can be null. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - A CBOR object corresponding to the given object. Returns - CBORObject.Null if the object is null. - - - Generates a CBORObject from an arbitrary object. See the - overload of this method that takes CBORTypeMapper and PODOptions - arguments. - The parameter is an - arbitrary object. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - An object containing options to control how - certain objects are converted to CBOR objects. - A CBOR object corresponding to the given object. Returns - CBORObject.Null if the object is null. - The parameter is null. - - - Generates a CBORObject from an arbitrary object. See the - overload of this method that takes CBORTypeMapper and PODOptions - arguments. - The parameter is an - arbitrary object. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - An object containing optional converters to - convert objects of certain types to CBOR objects. - A CBOR object corresponding to the given object. Returns - CBORObject.Null if the object is null. - The parameter is null. - - - Generates a CBORObject from an arbitrary object, - using the given options to control how certain objects are - converted to CBOR objects. The following cases are checked in the - logical order given (rather than the strict order in which they are - implemented by this library): - null - is - converted to CBORObject.Null - . - A - CBORObject - is returned as itself. - If the object - is of a type corresponding to a type converter mentioned in the - parameter, that converter will be used to - convert the object to a CBOR object. Type converters can be used to - override the default conversion behavior of almost any - object. - A char - is converted to an integer (from - 0 through 65535), and returns a CBOR object of that integer. (This - is a change in version 4.0 from previous versions, which converted - char - , except surrogate code points from 0xd800 through - 0xdfff, into single-character text strings.) - A - bool - ( boolean - in Java) is converted to - CBORObject.True - or CBORObject.False - . - A - byte - is converted to a CBOR integer from 0 through - 255. - A primitive integer type ( int - , - short - , long - , as well as sbyte - , - ushort - , uint - , and ulong - in.NET) is converted - to the corresponding CBOR integer. - A primitive - floating-point type ( float - , double - , as well as - decimal - in.NET) is converted to the corresponding CBOR - number. - A String - is converted to a CBOR text - string. To create a CBOR byte string object from String - , - see the example given in . - In the.NET version, a nullable is converted to - CBORObject.Null - if the nullable's value is null - , or - converted according to the nullable's underlying type, if that type - is supported by this method. - In the Java version, a - number of type BigInteger - or BigDecimal - is converted - to the corresponding CBOR number. - A number of type - EDecimal - , EFloat - , EInteger - , and - ERational - in the PeterO.Numbers - - library (in .NET) or the com.github.peteroupc/numbers - - artifact (in Java) is converted to the corresponding CBOR - number. - An array other than byte[] - is converted - to a CBOR array. In the.NET version, a multidimensional array is - converted to an array of arrays. - A byte[] - (1-dimensional byte array) is converted to a CBOR byte string; the - byte array is copied to a new byte array in this process. (This - method can't be used to decode CBOR data from a byte array; for - that, use the DecodeFromBytes - method instead.) - An object implementing IDictionary (Map in Java) is converted - to a CBOR map containing the keys and values enumerated. - An object implementing IEnumerable (Iterable in Java) is - converted to a CBOR array containing the items enumerated. - An enumeration ( Enum - ) object is converted to its - underlying value - in the.NET version, or the result of its - ordinal() - method in the Java version. - An object - of type DateTime - , Uri - , or Guid - ( Date - , URI - , or UUID - , respectively, in Java) will be - converted to a tagged CBOR object of the appropriate kind. By - default, DateTime - / Date - will be converted to a tag-0 - string following the date format used in the Atom syndication - format, but this behavior can be changed by passing a suitable - CBORTypeMapper to this method, such as a CBORTypeMapper that - registers a CBORDateConverter for DateTime - or Date - objects. See the examples. - If the object is a type not - specially handled above, this method checks the parameter for eligible getters as follows: - (*) In the .NET version, eligible getters are the public, - nonstatic getters of read/write properties (and also those of - read-only properties in the case of a compiler-generated type or an - F# type). Eligible getters also include public, nonstatic, non- - const - , non- readonly - fields. If a class has two - properties and/or fields of the form "X" and "IsX", where "X" is - any name, or has multiple properties and/or fields with the same - name, those properties and fields are ignored. - (*) In - the Java version, eligible getters are public, nonstatic methods - starting with "get" or "is" (either word followed by a character - other than a basic digit or lower-case letter, that is, other than - "a" to "z" or "0" to "9"), that take no parameters and do not - return void, except that methods named "getClass" are not eligible - getters. In addition, public, nonstatic, nonfinal fields are also - eligible getters. If a class has two otherwise eligible getters - (methods and/or fields) of the form "isX" and "getX", where "X" is - the same in both, or two such getters with the same name but - different return type, they are not eligible getters. - Then, the method returns a CBOR map with each eligible - getter's name or property name as each key, and with the - corresponding value returned by that getter as that key's value. - Before adding a key-value pair to the map, the key's name is - adjusted according to the rules described in the documentation. Note that for - security reasons, certain types are not supported even if they - contain eligible getters. - - REMARK: - .NET - enumeration ( Enum - ) constants could also have been - converted to text strings with ToString() - , but that method - will return multiple names if the given Enum object is a - combination of Enum objects (e.g. if the object is - FileAccess.Read | FileAccess.Write - ). More generally, if - Enums are converted to text strings, constants from Enum types with - the Flags - attribute, and constants from the same Enum type - that share an underlying value, should not be passed to this - method. - - An arbitrary object to convert to a CBOR object. - NOTE: - For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int - or String - ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - . - An object containing optional converters to - convert objects of certain types to CBOR objects. Can be - null. - An object containing options to control how - certain objects are converted to CBOR objects. - A CBOR object corresponding to the given object. Returns - CBORObject.Null if the object is null. - The parameter is null. - An error occurred while - converting the given object to a CBOR object. - - The following example (originally written in C# for the - DotNet version) uses a CBORTypeMapper to change how DateTime - objects are converted to CBOR. In this case, such objects are - converted to CBOR objects with tag 1 that store numbers giving the - number of seconds since the start of 1970. - var conv = new CBORTypeMapper().AddConverter(typeof(DateTime), - CBORDateConverter.TaggedNumber); - CBORObject obj = CBORObject.FromObject(DateTime.Now, conv); - The following example generates a CBOR object from a 64-bit - signed integer that is treated as a 64-bit unsigned integer (such - as DotNet's UInt64, which has no direct equivalent in the Java - language), in the sense that the value is treated as 2^64 plus the - original value if it's negative. - long x = -40L; /* Example 64-bit value treated as 2^64-40.*/ - CBORObject obj = CBORObject.FromObject( - v < 0 ? EInteger.FromInt32(1).ShiftLeft(64).Add(v) : - EInteger.FromInt64(v)); - In the Java version, which has java.math.BigInteger, the - following can be used instead: - long x = -40L; /* Example 64-bit value treated as 2^64-40.*/ - CBORObject obj = CBORObject.FromObject( - v < 0 ? BigInteger.valueOf(1).shiftLeft(64).add(BigInteger.valueOf(v)) : - BigInteger.valueOf(v)); - - - - Generates a CBOR object from this one, but gives the - resulting object a tag in addition to its existing tags (the new - tag is made the outermost tag). - Tag number. The tag number 55799 can be - used to mark a "self-described CBOR" object. This document does not - attempt to list all CBOR tags and their meanings. An up-to-date - list can be found at the CBOR Tags registry maintained by the - Internet Assigned Numbers Authority( - iana.org/assignments/cbor-tags ). - A CBOR object with the same value as this one but given - the tag in addition to its existing - tags (the new tag is made the outermost tag). - The parameter is less than 0 or greater than - 2^64-1. - The parameter is null. - - - Generates a CBOR object from an arbitrary object and gives - the resulting object a tag in addition to its existing tags (the - new tag is made the outermost tag). - The parameter is - an arbitrary object, which can be null. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - Tag number. The tag number 55799 can be - used to mark a "self-described CBOR" object. This document does not - attempt to list all CBOR tags and their meanings. An up-to-date - list can be found at the CBOR Tags registry maintained by the - Internet Assigned Numbers Authority( - iana.org/assignments/cbor-tags ). - A CBOR object where the object - is converted to a CBOR object and given the tag . If is null, returns - a version of CBORObject.Null with the given tag. - The parameter is less than 0 or greater than - 2^64-1. - The parameter is null. - - - Generates a CBOR object from an arbitrary object and gives - the resulting object a tag in addition to its existing tags (the - new tag is made the outermost tag). - A 32-bit integer that specifies a tag - number. The tag number 55799 can be used to mark a "self-described - CBOR" object. This document does not attempt to list all CBOR tags - and their meanings. An up-to-date list can be found at the CBOR - Tags registry maintained by the Internet Assigned Numbers Authority - ( - iana.org/assignments/cbor-tags ). - A CBOR object with the same value as this one but given - the tag in addition to its existing - tags (the new tag is made the outermost tag). - The parameter is less than 0. - - - Generates a CBOR object from an arbitrary object and gives - the resulting object a tag in addition to its existing tags (the - new tag is made the outermost tag). - The parameter is an arbitrary object, which can be null. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - A 32-bit integer that specifies a tag - number. The tag number 55799 can be used to mark a "self-described - CBOR" object. This document does not attempt to list all CBOR tags - and their meanings. An up-to-date list can be found at the CBOR - Tags registry maintained by the Internet Assigned Numbers Authority - ( - iana.org/assignments/cbor-tags ). - A CBOR object where the object is converted to a CBOR object and given the - tag . If "valueOb" is null, returns a - version of CBORObject.Null with the given tag. - The parameter is less than 0. - - - Creates a CBOR object from a simple value - number. - The parameter is a 32-bit signed integer. - A CBOR object. - The parameter is less than 0, greater than 255, or from 24 - through 31. - - - Multiplies two CBOR numbers. - The parameter is a - CBOR object. - The parameter is a - CBOR object. - The product of the two numbers. - Either or both operands are not - numbers (as opposed to Not-a-Number, NaN). - The parameter or is null. - - - Creates a new empty CBOR array. - A new CBOR array. - - - Creates a new empty CBOR map that stores its keys in an - undefined order. - A new CBOR map. - - - Creates a new empty CBOR map that ensures that keys are - stored in the order in which they are first inserted. - A new CBOR map. - - - - Reads a sequence of objects in CBOR format from a data - stream. This method will read CBOR objects from the stream until - the end of the stream is reached or an error occurs, whichever - happens first. - A readable data stream. - An array containing the CBOR objects that were read from - the data stream. Returns an empty array if there is no unread data - in the stream. - The parameter is null, or the parameter "options" is - null. - There was an error in - reading or parsing the data, including if the last CBOR object was - read only partially. - - - - Reads a sequence of objects in CBOR format from a data - stream. This method will read CBOR objects from the stream until - the end of the stream is reached or an error occurs, whichever - happens first. - A readable data stream. - Specifies the options to use when decoding - the CBOR data stream. See CBOREncodeOptions for more information. - In this method, the AllowEmpty property is treated as set - regardless of the value of that property specified in this - parameter. - An array containing the CBOR objects that were read from - the data stream. Returns an empty array if there is no unread data - in the stream. - The parameter is null, or the parameter is null. - There was an error in - reading or parsing the data, including if the last CBOR object was - read only partially. - - - - Reads an object in CBOR format from a data stream. This - method will read from the stream until the end of the CBOR object - is reached or an error occurs, whichever happens - first. - A readable data stream. - A CBOR object that was read. - The parameter is null. - There was an error in - reading or parsing the data. - - - Reads an object in CBOR format from a data stream, using - the specified options to control the decoding process. This method - will read from the stream until the end of the CBOR object is - reached or an error occurs, whichever happens first. - A readable data stream. - Specifies the options to use when decoding - the CBOR data stream. See CBOREncodeOptions for more - information. - A CBOR object that was read. - The parameter is null. - There was an error in - reading or parsing the data. - - - Generates a CBOR object from a data stream in JavaScript - Object Notation (JSON) format. The JSON stream may begin with a - byte-order mark (U+FEFF). Since version 2.0, the JSON stream can be - in UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by - assuming that the first character read must be a byte-order mark or - a nonzero basic character (U+0001 to U+007F). (In previous - versions, only UTF-8 was allowed.). (This behavior may change to - supporting only UTF-8, with or without a byte order mark, in - version 5.0 or later, perhaps with an option to restore the - previous behavior of also supporting UTF-16 and UTF-32.). - A readable data stream. The sequence of bytes - read from the data stream must contain a single JSON object and not - multiple objects. - A CBOR object. - The parameter is null. - An I/O error - occurred. - The data stream - contains invalid encoding or is not in JSON format. - - - Generates a list of CBOR objects from a data stream in - JavaScript Object Notation (JSON) text sequence format (RFC 7464). - The data stream must be in UTF-8 encoding and may not begin with a - byte-order mark (U+FEFF). - A readable data stream. The sequence of bytes - read from the data stream must either be empty or begin with a - record separator byte (0x1e). - A list of CBOR objects read from the JSON sequence. - Objects that could not be parsed are replaced with null (as - opposed to CBORObject.Null ) in the given list. - The parameter is null. - An I/O error - occurred. - The data stream is not - empty and does not begin with a record separator byte - (0x1e). - Generally, each JSON text in a JSON text sequence is - written as follows: Write a record separator byte (0x1e), then - write the JSON text in UTF-8 (without a byte order mark, U+FEFF), - then write the line feed byte (0x0a). RFC 7464, however, uses a - more liberal syntax for parsing JSON text sequences. - - - Generates a CBOR object from a data stream in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. The JSON stream may begin with a - byte-order mark (U+FEFF). Since version 2.0, the JSON stream can be - in UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by - assuming that the first character read must be a byte-order mark or - a nonzero basic character (U+0001 to U+007F). (In previous - versions, only UTF-8 was allowed.). - A readable data stream. The sequence of bytes - read from the data stream must contain a single JSON object and not - multiple objects. - Contains options to control the JSON decoding - process. This method uses only the AllowDuplicateKeys property of - this object. - A CBOR object containing the JSON data decoded. - The parameter is null. - An I/O error - occurred. - The data stream - contains invalid encoding or is not in JSON format. - - - Generates a list of CBOR objects from a data stream in - JavaScript Object Notation (JSON) text sequence format (RFC 7464). - The data stream must be in UTF-8 encoding and may not begin with a - byte-order mark (U+FEFF). - A readable data stream. The sequence of bytes - read from the data stream must either be empty or begin with a - record separator byte (0x1e). - Specifies options to control how JSON - texts in the stream are decoded to CBOR. See the JSONOptions - class. - A list of CBOR objects read from the JSON sequence. - Objects that could not be parsed are replaced with null (as - opposed to CBORObject.Null ) in the given list. - The parameter is null. - An I/O error - occurred. - The data stream is not - empty and does not begin with a record separator byte - (0x1e). - Generally, each JSON text in a JSON text sequence is - written as follows: Write a record separator byte (0x1e), then - write the JSON text in UTF-8 (without a byte order mark, U+FEFF), - then write the line feed byte (0x0a). RFC 7464, however, uses a - more liberal syntax for parsing JSON text sequences. - - - Generates a CBOR object from a data stream in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. The JSON stream may begin with a - byte-order mark (U+FEFF). Since version 2.0, the JSON stream can be - in UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by - assuming that the first character read must be a byte-order mark or - a nonzero basic character (U+0001 to U+007F). (In previous - versions, only UTF-8 was allowed.). (This behavior may change to - supporting only UTF-8, with or without a byte order mark, in - version 5.0 or later, perhaps with an option to restore the - previous behavior of also supporting UTF-16 and UTF-32.). - A readable data stream. The sequence of bytes - read from the data stream must contain a single JSON object and not - multiple objects. - Specifies options to control how the JSON - stream is decoded to CBOR. See the JSONOptions class. - A CBOR object containing the JSON data decoded. - The parameter is null. - An I/O error - occurred. - The data stream - contains invalid encoding or is not in JSON format. - - - - Generates a CBOR object from a byte array in JavaScript - Object Notation (JSON) format. - If a JSON object has duplicate keys, a CBORException is - thrown. - Note that if a CBOR object is converted to JSON with - ToJSONBytes, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A byte array in JSON format. The entire byte - array must contain a single JSON object and not multiple objects. - The byte array may begin with a byte-order mark (U+FEFF). The byte - array can be in UTF-8, UTF-16, or UTF-32 encoding; the encoding is - detected by assuming that the first character read must be a - byte-order mark or a nonzero basic character (U+0001 to U+007F). - (This behavior may change to supporting only UTF-8, with or without - a byte order mark, in version 5.0 or later, perhaps with an option - to restore the previous behavior of also supporting UTF-16 and - UTF-32.). - A CBOR object containing the JSON data decoded. - The parameter is null. - The byte array contains - invalid encoding or is not in JSON format. - - - Generates a CBOR object from a byte array in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. - Note that if a CBOR object is converted to JSON with - ToJSONBytes, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A byte array in JSON format. The entire byte - array must contain a single JSON object and not multiple objects. - The byte array may begin with a byte-order mark (U+FEFF). The byte - array can be in UTF-8, UTF-16, or UTF-32 encoding; the encoding is - detected by assuming that the first character read must be a - byte-order mark or a nonzero basic character (U+0001 to U+007F). - (This behavior may change to supporting only UTF-8, with or without - a byte order mark, in version 5.0 or later, perhaps with an option - to restore the previous behavior of also supporting UTF-16 and - UTF-32.). - Specifies options to control how the JSON - data is decoded to CBOR. See the JSONOptions class. - A CBOR object containing the JSON data decoded. - The parameter or is - null. - The byte array contains - invalid encoding or is not in JSON format. - - - - Generates a CBOR object from a byte array in JavaScript - Object Notation (JSON) format. - If a JSON object has duplicate keys, a CBORException is - thrown. - Note that if a CBOR object is converted to JSON with - ToJSONBytes, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A byte array, the specified portion of which is - in JSON format. The specified portion of the byte array must - contain a single JSON object and not multiple objects. The portion - may begin with a byte-order mark (U+FEFF). The portion can be in - UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by - assuming that the first character read must be a byte-order mark or - a nonzero basic character (U+0001 to U+007F). (This behavior may - change to supporting only UTF-8, with or without a byte order mark, - in version 5.0 or later, perhaps with an option to restore the - previous behavior of also supporting UTF-16 and UTF-32.). - An index, starting at 0, showing where the - desired portion of begins. - The length, in bytes, of the desired portion of - (but not more than 's length). - A CBOR object containing the JSON data decoded. - The parameter is null. - The byte array contains - invalid encoding or is not in JSON format. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Generates a CBOR object from a byte array in JavaScript - Object Notation (JSON) format, using the specified options to - control the decoding process. - Note that if a CBOR object is converted to JSON with - ToJSONBytes, then the JSON is converted back to CBOR with - this method, the new CBOR object will not necessarily be the same - as the old CBOR object, especially if the old CBOR object uses data - types not supported in JSON, such as integers in map - keys. - A byte array, the specified portion of which is - in JSON format. The specified portion of the byte array must - contain a single JSON object and not multiple objects. The portion - may begin with a byte-order mark (U+FEFF). The portion can be in - UTF-8, UTF-16, or UTF-32 encoding; the encoding is detected by - assuming that the first character read must be a byte-order mark or - a nonzero basic character (U+0001 to U+007F). (This behavior may - change to supporting only UTF-8, with or without a byte order mark, - in version 5.0 or later, perhaps with an option to restore the - previous behavior of also supporting UTF-16 and UTF-32.). - An index, starting at 0, showing where the - desired portion of begins. - The length, in bytes, of the desired portion of - (but not more than 's length). - Specifies options to control how the JSON - data is decoded to CBOR. See the JSONOptions class. - A CBOR object containing the JSON data decoded. - The parameter or is - null. - The byte array contains - invalid encoding or is not in JSON format. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Finds the remainder that results when a CBORObject object - is divided by the value of a CBOR object. - The parameter is a - CBOR object. - The parameter is a - CBOR object. - The remainder of the two numbers. - The parameter or is null. - - - Finds the difference between two CBOR number - objects. - The parameter is a - CBOR object. - The parameter is a - CBOR object. - The difference of the two objects. - Either or both operands are not - numbers (as opposed to Not-a-Number, NaN). - The parameter or is null. - - - - Writes a text string in CBOR format to a data stream. The - string will be encoded using definite-length encoding regardless of - its length. - The string to write. Can be null. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a text string in CBOR format to a data stream, - using the given options to control the encoding process. - The string to write. Can be null. - A writable data stream. - Options for encoding the data to - CBOR. - The parameter is null. - An I/O error - occurred. - - - Writes a binary floating-point number in CBOR format to a - data stream, as though it were converted to a CBOR object via - CBORObject.FromObject(EFloat) and then written out. - An arbitrary-precision binary floating-point - number. Can be null. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a rational number in CBOR format to a data stream, - as though it were converted to a CBOR object via - CBORObject.FromObject(ERational) and then written out. - An arbitrary-precision rational number. Can - be null. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a decimal floating-point number in CBOR format to a - data stream, as though it were converted to a CBOR object via - CBORObject.FromObject(EDecimal) and then written out. - The arbitrary-precision decimal number to - write. Can be null. - Stream to write to. - The parameter is null. - An I/O error - occurred. - - - Writes a arbitrary-precision integer in CBOR format to a - data stream. - Arbitrary-precision integer to write. Can be - null. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a 64-bit signed integer in CBOR format to a data - stream. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a 32-bit signed integer in CBOR format to a data - stream. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a 16-bit signed integer in CBOR format to a data - stream. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a Boolean value in CBOR format to a data - stream. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a byte (0 to 255) in CBOR format to a data stream. - If the value is less than 24, writes that byte. If the value is 25 - to 255, writes the byte 24, then this byte's value. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a 32-bit floating-point number in CBOR format to a - data stream. The number is written using the shortest - floating-point encoding possible; this is a change from previous - versions. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a 64-bit floating-point number in CBOR format to a - data stream. The number is written using the shortest - floating-point encoding possible; this is a change from previous - versions. - The value to write. - A writable data stream. - The parameter is null. - An I/O error - occurred. - - - Writes a CBOR object to a CBOR data stream. - The value to write. Can be null. - A writable data stream. - The parameter is null. - - - - Writes a CBOR object to a CBOR data stream. See the - three-parameter Write method that takes a - CBOREncodeOptions. - The arbitrary object to be serialized. Can - be null. - A writable data stream. - - - Writes an arbitrary object to a CBOR data stream, using - the specified options for controlling how the object is encoded to - CBOR data format. If the object is convertible to a CBOR map or a - CBOR object that contains CBOR maps, the order in which the keys to - those maps are written out to the data stream is undefined unless - the map was created using the NewOrderedMap method. The example - code given in - can - be used to write out certain keys of a CBOR map in a given order. - Currently, the following objects are supported: - - Lists of CBORObject. - Maps of CBORObject. The order in which the keys to the map - are written out to the data stream is undefined unless the map was - created using the NewOrderedMap method. - Null. - Byte arrays, which will always be written as definite-length - byte strings. - String objects. The strings will be encoded using - definite-length encoding regardless of their length. - Any object accepted by the FromObject static - methods. - The arbitrary object to be serialized. Can - be null. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - A writable data stream. - CBOR options for encoding the CBOR object to - bytes. - The object's type is not - supported. - The parameter or is null. - - - Converts an arbitrary object to a text string in - JavaScript Object Notation (JSON) format, as in the ToJSONString - method, and writes that string to a data stream in UTF-8. If the - object is convertible to a CBOR map, or to a CBOR object that - contains CBOR maps, the order in which the keys to those maps are - written out to the JSON string is undefined unless the map was - created using the NewOrderedMap method. The example code given in - PeterO.Cbor.CBORObject.ToJSONString(PeterO.Cbor.JSONOptions) - can be used to write out certain keys of a CBOR map in a given - order to a JSON string. - The parameter is an - arbitrary object. Can be null. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - A writable data stream. - The parameter is null. - - - Gets this object's absolute value. - This object's absolute without its negative - sign. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - - - - Adds a new key and its value to this CBOR map, or adds the - value if the key doesn't exist. - NOTE: This method can't be used to add a tag to an existing - CBOR object. To create a CBOR object with a given tag, call the - CBORObject.FromObjectAndTag method and pass the CBOR object - and the desired tag number to that method. - An object representing the key, which will be - converted to a CBORObject. Can be null, in which case this value is - converted to CBORObject.Null. - An object representing the value, which will - be converted to a CBORObject. Can be null, in which case this value - is converted to CBORObject.Null. - This instance. - The parameter already exists in this map. - This object is not a - map. - The parameter or has an unsupported - type. - - - Adds a new object to the end of this array. (Used to - throw ArgumentNullException on a null reference, but now converts - the null reference to CBORObject.Null, for convenience with the - Object overload of this method). - NOTE: This method - can't be used to add a tag to an existing CBOR object. To create a - CBOR object with a given tag, call the - CBORObject.FromObjectAndTag - method and pass the CBOR object - and the desired tag number to that method. - - The parameter is a CBOR - object. - This instance. - This object is not an - array. - - The following example creates a CBOR array and adds several - CBOR objects, one of which has a custom CBOR tag, to that array. - Note the chaining behavior made possible by this method. - CBORObject obj = CBORObject.NewArray() .Add(CBORObject.False) - .Add(CBORObject.FromObject(5)) .Add(CBORObject.FromObject("text - string")) .Add(CBORObject.FromObjectAndTag(9999, 1)); - . - - - - Converts an object to a CBOR object and adds it to - the end of this array. - NOTE: This method can't be used - to add a tag to an existing CBOR object. To create a CBOR object - with a given tag, call the CBORObject.FromObjectAndTag - method and pass the CBOR object and the desired tag number to that - method. - - A CBOR object (or an object convertible to a CBOR - object) to add to this CBOR array. - This instance. - This instance is not an - array. - The type of is not supported. - - The following example creates a CBOR array and adds several - CBOR objects, one of which has a custom CBOR tag, to that array. - Note the chaining behavior made possible by this method. - CBORObject obj = CBORObject.NewArray() .Add(CBORObject.False) .Add(5) - .Add("text string") .Add(CBORObject.FromObjectAndTag(9999, 1)); - . - - - - Converts this object to an arbitrary-precision integer. - See the ToObject overload taking a type for more - information. - The closest arbitrary-precision integer to this - object. - This object does not - represent a number (for the purposes of this method, infinity and - not-a-number values, but not CBORObject.Null, are - considered numbers). - This object's value is infinity - or not-a-number (NaN). - - - Returns false if this object is a CBOR false, null, or - undefined value (whether or not the object has tags); otherwise, - true. - False if this object is a CBOR false, null, or undefined - value; otherwise, true. - - - Converts this object to a byte (0 to 255). Floating point - values are converted to integers by discarding their fractional - parts. - The closest byte-sized integer to this object. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value exceeds the - range of a byte (would be less than 0 or greater than 255 when - converted to an integer by discarding its fractional - part). - - - Converts this object to a 64-bit floating point - number. - The closest 64-bit floating point number to this object. - The return value can be positive infinity or negative infinity if - this value exceeds the range of a 64-bit floating point - number. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - - - Converts this object to a decimal number. - A decimal number for this object's value. - This object does not - represent a number (for the purposes of this method, infinity and - not-a-number values, but not CBORObject.Null, are - considered numbers). - - - Converts this object to an arbitrary-precision binary - floating point number. See the ToObject overload taking a type for - more information. - An arbitrary-precision binary floating-point number for - this object's value. - This object does not - represent a number (for the purposes of this method, infinity and - not-a-number values, but not CBORObject.Null, are - considered numbers). - - - Converts this object to a rational number. See the - ToObject overload taking a type for more information. - A rational number for this object's value. - This object does not - represent a number (for the purposes of this method, infinity and - not-a-number values, but not CBORObject.Null, are - considered numbers). - - - Converts this object to a 16-bit signed integer. Floating - point values are converted to integers by discarding their - fractional parts. - The closest 16-bit signed integer to this - object. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value exceeds the - range of a 16-bit signed integer. - - - Converts this object to a 32-bit signed integer if this - CBOR object's type is Integer. This method disregards the tags this - object has, if any. - The 32-bit signed integer stored by this object. - This object's type is - not CBORType.Integer - . - This object's value exceeds the - range of a 32-bit signed integer. - - The following example code (originally written in C# for - the.NET Framework) shows a way to check whether a given CBOR object - stores a 32-bit signed integer before getting its value. - CBORObject obj = CBORObject.FromInt32(99999); - if (obj.CanValueFitInInt32()) { /* Not an Int32; - handle the error */ Console.WriteLine("Not a 32-bit integer."); } else { - Console.WriteLine("The value is " + obj.AsInt32Value()); } - . - - - - Converts this object to a 64-bit signed integer if this - CBOR object's type is Integer. This method disregards the tags this - object has, if any. - The 64-bit signed integer stored by this object. - This object's type is - not CBORType.Integer - . - This object's value exceeds the - range of a 64-bit signed integer. - - The following example code (originally written in C# for - the.NET Framework) shows a way to check whether a given CBOR object - stores a 64-bit signed integer before getting its value. - CBORObject obj = CBORObject.FromInt64(99999); - if (obj.CanValueFitInInt64()) { - /* Not an Int64; handle the error*/ - Console.WriteLine("Not a 64-bit integer."); } else { - Console.WriteLine("The value is " + obj.AsInt64Value()); } - . - - - - Returns whether this CBOR object stores an integer - (CBORType.Integer) within the range of a 64-bit signed integer. - This method disregards the tags this object has, if any. - true if this CBOR object stores an integer - (CBORType.Integer) whose value is at least -(2^63) and less than - 2^63; otherwise, false. - - - Returns whether this CBOR object stores an integer - (CBORType.Integer) within the range of a 32-bit signed integer. - This method disregards the tags this object has, if any. - true if this CBOR object stores an integer - (CBORType.Integer) whose value is at least -(2^31) and less than - 2^31; otherwise, false. - - - Converts this object to an arbitrary-precision integer if - this CBOR object's type is Integer. This method disregards the tags - this object has, if any. (Note that CBOR stores untagged integers - at least -(2^64) and less than 2^64.). - The integer stored by this object. - This object's type is - not CBORType.Integer. - - - Converts this object to the bits of a 64-bit - floating-point number if this CBOR object's type is FloatingPoint. - This method disregards the tags this object has, if any. - The bits of a 64-bit floating-point number stored by this - object. The most significant bit is the sign (set means negative, - clear means nonnegative); the next most significant 11 bits are the - exponent area; and the remaining bits are the significand area. If - all the bits of the exponent area are set and the significand area - is 0, this indicates infinity. If all the bits of the exponent area - are set and the significand area is other than 0, this indicates - not-a-number (NaN). - This object's type is - not CBORType.FloatingPoint. - - - Converts this object to a 64-bit floating-point number if - this CBOR object's type is FloatingPoint. This method disregards - the tags this object has, if any. - The 64-bit floating-point number stored by this - object. - This object's type is - not CBORType.FloatingPoint. - - - Converts this object to a CBOR number. (NOTE: To determine - whether this method call can succeed, call the IsNumber - property (isNumber() method in Java) before calling this - method.). - The number represented by this object. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - - - Converts this object to a 32-bit signed integer. - Non-integer number values are converted to integers by discarding - their fractional parts. (NOTE: To determine whether this method - call can succeed, call AsNumber().CanTruncatedIntFitInInt32 - before calling this method. See the example.). - The closest 32-bit signed integer to this - object. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value exceeds the - range of a 32-bit signed integer. - - The following example code (originally written in C# for - the.NET Framework) shows a way to check whether a given CBOR object - stores a 32-bit signed integer before getting its value. - CBORObject obj = CBORObject.FromInt32(99999); - if (obj.AsNumber().CanTruncatedIntFitInInt32()) { - /* Not an Int32; handle the error */ - Console.WriteLine("Not a 32-bit integer."); } else { - Console.WriteLine("The value is " + obj.AsInt32()); } - . - - - - Converts this object to a 64-bit signed integer. - Non-integer numbers are converted to integers by discarding their - fractional parts. (NOTE: To determine whether this method call can - succeed, call AsNumber().CanTruncatedIntFitInInt64 - before - calling this method. See the example.). - The closest 64-bit signed integer to this - object. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value exceeds the - range of a 64-bit signed integer. - - The following example code (originally written in C# for - the.NET Framework) shows a way to check whether a given CBOR object - stores a 64-bit signed integer before getting its value. - CBORObject obj = CBORObject.FromInt64(99999); - if (obj.IsIntegral && obj.AsNumber().CanFitInInt64()) { - /* Not an Int64; handle the error */ - Console.WriteLine("Not a 64-bit integer."); } else { - Console.WriteLine("The value is " + obj.AsInt64()); } - . - - - - Converts this object to a 32-bit floating point - number. - The closest 32-bit floating point number to this object. - The return value can be positive infinity or negative infinity if - this object's value exceeds the range of a 32-bit floating point - number. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - - - Gets the value of this object as a text string. - Gets this object's string. - This object's type is - not a text string (for the purposes of this method, infinity and - not-a-number values, but not CBORObject.Null, are - considered numbers). To check the CBOR object for null before - conversion, use the following idiom (originally written in C# for - the.NET version): (cbor == null || cbor.IsNull) ? null : - cbor.AsString(). - This method is not the "reverse" of the FromObject - method in the sense that FromObject can take either a text string - or null, but this method can accept only text strings. The - ToObject method is closer to a "reverse" version to - FromObject than the AsString method: - ToObject<String>(cbor) in DotNet, or - ToObject(String.class) in Java, will convert a CBOR object - to a DotNet or Java String if it represents a text string, or to - null if IsNull returns true for the CBOR - object, and will fail in other cases. - - - 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. - 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. - - - Returns whether this object's numerical value is an - integer, is -(2^31) or greater, and is less than 2^31. - true if this object's numerical value is an - integer, is -(2^31) or greater, and is less than 2^31; otherwise, - false. - - - Returns whether this object's numerical value is an - integer, is -(2^63) or greater, and is less than 2^63. - true if this object's numerical value is an - integer, is -(2^63) or greater, and is less than 2^63; otherwise, - false. - - - 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. - 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. - - - 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. - 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. - - - 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. - 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. - - - Compares two CBOR objects. This implementation was changed - in version 4.0. - In this implementation: - - The null pointer (null reference) is considered less than any - other object. - If the two objects are both integers (CBORType.Integer) both - floating-point values, both byte strings, both simple values - (including True and False), or both text strings, their CBOR - encodings (as though EncodeToBytes were called on each integer) are - compared as though by a byte-by-byte comparison. (This means, for - example, that positive integers sort before negative - integers). - If both objects have a tag, they are compared first by the - tag's value then by the associated item (which itself can have a - tag). - If both objects are arrays, they are compared item by item. - In this case, if the arrays have different numbers of items, the - array with more items is treated as greater than the other - array. - If both objects are maps, their key-value pairs, sorted by - key in accordance with this method, are compared, where each pair - is compared first by key and then by value. In this case, if the - maps have different numbers of key-value pairs, the map with more - pairs is treated as greater than the other map. - If the two objects have different types, the object whose - type comes first in the order of untagged integers, untagged byte - strings, untagged text strings, untagged arrays, untagged maps, - tagged objects, untagged simple values (including True and False) - and untagged floating point values sorts before the other - object. - This method is consistent with the Equals - method. - A value to compare with. - 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 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.. - - - Compares this object and another CBOR object, ignoring the - tags they have, if any. See the CompareTo method for more - information on the comparison function. - A value to compare with. - Less than 0, if this value is less than the other object; - or 0, if both values are equal; or greater than 0, if this value is - less than the other object or if the other object is - null. - - - Determines whether a value of the given key exists in this - object. - The parameter is an - arbitrary object. - true if the given key is found, or false if - the given key is not found or this object is not a map. - - - Determines whether a value of the given key exists in this - object. - An object that serves as the key. If this is - null, checks for CBORObject.Null. - true if the given key is found, or false if - the given key is not found or this object is not a map. - - - Determines whether a value of the given key exists in this - object. - A text string that serves as the key. If this is - null, checks for CBORObject.Null. - true if the given key (as a CBOR object) is found, - or false if the given key is not found or this object is not - a map. - - - - Writes the binary representation of this CBOR object and - returns a byte array of that representation. If the CBOR object - contains CBOR maps, or is a CBOR map itself, the order in which the - keys to the map are written out to the byte array is undefined - unless the map was created using the NewOrderedMap method. The - example code given in - can - be used to write out certain keys of a CBOR map in a given order. - For the CTAP2 (FIDO Client-to-Authenticator Protocol 2) canonical - ordering, which is useful for implementing Web Authentication, call - EncodeToBytes(new CBOREncodeOptions("ctap2canonical=true")) - rather than this method. - A byte array in CBOR format. - - - Writes the binary representation of this CBOR object and - returns a byte array of that representation, using the specified - options for encoding the object to CBOR format. For the CTAP2 (FIDO - Client-to-Authenticator Protocol 2) canonical ordering, which is - useful for implementing Web Authentication, call this method as - follows: EncodeToBytes(new - CBOREncodeOptions("ctap2canonical=true")). - Options for encoding the data to - CBOR. - A byte array in CBOR format. - The parameter is null. - - - Gets the CBOR object referred to by a JSON Pointer - according to RFC6901. For more information, see the overload taking - a default value parameter. - A JSON pointer according to RFC 6901. - An object within this CBOR object. Returns this object if - pointer is the empty string (even if this object has a CBOR type - other than array or map). - Thrown if the pointer - is null, or if the pointer is invalid, or if there is no object at - the given pointer, or the special key "-" appears in the pointer in - the context of an array (not a map), or if the pointer is non-empty - and this object has a CBOR type other than array or - map. - - - Gets the CBOR object referred to by a JSON Pointer - according to RFC6901, or a default value if the operation fails. - The syntax for a JSON Pointer is: -
'/' KEY '/' KEY [...]
where KEY represents a key into - the JSON object or its sub-objects in the hierarchy. For example, -
/foo/2/bar
means the same as -
obj['foo'][2]['bar']
in JavaScript. If "~" and/or "/" - occurs in a key, it must be escaped with "~0" or "~1", - respectively, in a JSON pointer. JSON pointers also support the - special key "-" (as in "/foo/-") to indicate the end of an array, - but this method treats this key as an error since it refers to a - nonexistent item. Indices to arrays (such as 2 in the example) must - contain only basic digits 0 to 9 and no leading zeros. (Note that - RFC 6901 was published before JSON was extended to support - top-level values other than arrays and key-value - dictionaries.).
- A JSON pointer according to RFC 6901. - The parameter is a Cbor.CBORObject object. - An object within the specified JSON object. Returns this - object if pointer is the empty string (even if this object has a - CBOR type other than array or map). Returns if the pointer is null, or if the pointer is - invalid, or if there is no object at the given pointer, or the - special key "-" appears in the pointer in the context of an array - (not a map), or if the pointer is non-empty and this object has a - CBOR type other than array or map. -
- - Returns a copy of this object after applying the - operations in a JSON patch, in the form of a CBOR object. JSON - patches are specified in RFC 6902 and their format is summarized in - the remarks below. - A JSON patch in the form of a CBOR object; it - has the form summarized in the remarks. - The result of the patch operation. - The parameter is null or the patch operation failed. - Remarks: A JSON patch is an array with one or more - maps. Each map has the following keys: - - "op" - Required. This key's value is the patch operation and - must be "add", "remove", "move", "copy", "test", or "replace", in - basic lower case letters and no other case combination. - "value" - Required if the operation is "add", "replace", or - "test" and specifies the item to add (insert), or that will replace - the existing item, or to check an existing item for equality, - respectively. (For "test", the operation fails if the existing item - doesn't match the specified value.) - "path" - Required for all operations. A JSON Pointer (RFC - 6901) specifying the destination path in the CBOR object for the - operation. For more information, see RFC 6901 or the documentation - for AtJSONPointer(pointer, defaultValue). - "from" - Required if the operation is "move" or "copy". A - JSON Pointer (RFC 6901) specifying the path in the CBOR object - where the source value is located. - - - Determines whether this object and another object are - equal and have the same type. Not-a-number values can be considered - equal by this method. - The parameter is an - arbitrary object. - true if the objects are equal; otherwise, - false. In this method, two objects are not equal if they - don't have the same type or if one is null and the other - isn't. - - - Compares the equality of two CBOR objects. Not-a-number - values can be considered equal by this method. - The object to compare. - true if the objects are equal; otherwise, - false. In this method, two objects are not equal if they - don't have the same type or if one is null and the other - isn't. - - - Gets the backing byte array used in this CBOR object, if - this object is a byte string, without copying the data to a new - byte array. Any changes in the returned array's contents will be - reflected in this CBOR object. Note, though, that the array's - length can't be changed. - The byte array held by this CBOR object. - This object is not a - byte string. - - - Calculates the hash code of this object. The hash code for - a given instance of this class is not guaranteed to be the same - across versions of this class, and no application or process IDs - are used in the hash code calculation. - A 32-bit hash code. - - - Gets a list of all tags, from outermost to - innermost. - An array of tags, or the empty string if this object is - untagged. - - - Returns whether this object has only one tag. - true if this object has only one tag; otherwise, - false. - - - Returns whether this object has only one tag and that tag - is the given number. - The tag number. - true if this object has only one tag and that tag - is the given number; otherwise, false. - The parameter is less than 0. - - - Returns whether this object has only one tag and that tag - is the given number, expressed as an arbitrary-precision - integer. - An arbitrary-precision integer. - true if this object has only one tag and that tag - is the given number; otherwise, false. - The parameter is null. - The parameter is less than 0. - - - Gets the number of tags this object has. - The number of tags this object has. - - - Returns whether this object has an innermost tag and that - tag is of the given number. - The tag number. - true if this object has an innermost tag and that - tag is of the given number; otherwise, false. - The parameter is less than 0. - - - Returns whether this object has an innermost tag and that - tag is of the given number, expressed as an arbitrary-precision - number. - The tag number. - true if this object has an innermost tag and that - tag is of the given number; otherwise, false. - The parameter is null. - The parameter is less than 0. - - - Returns whether this object has an outermost tag and that - tag is of the given number. - The tag number. - true if this object has an outermost tag and that - tag is of the given number; otherwise, false. - The parameter is less than 0. - - - Returns whether this object has an outermost tag and that - tag is of the given number. - The tag number. - true if this object has an outermost tag and that - tag is of the given number; otherwise, false. - The parameter is null. - The parameter is less than 0. - - - Returns whether this object has a tag of the given - number. - The tag value to search for. - true if this object has a tag of the given number; - otherwise, false. - The parameter is less than 0. - The parameter is null. - - - Returns whether this object has a tag of the given - number. - The tag value to search for. - true if this object has a tag of the given number; - otherwise, false. - The parameter is null. - The parameter is less than 0. - - - Inserts an object at the specified position in this CBOR - array. - Index starting at 0 to insert at. - An object representing the value, which will - be converted to a CBORObject. Can be null, in which case this value - is converted to CBORObject.Null. - This instance. - This object is not an - array. - The parameter has an unsupported type; or is not a valid index into this array. - - - Gets a value indicating whether this CBOR object - represents infinity. - true if this CBOR object represents infinity; - otherwise, false. - - - Gets a value indicating whether this CBOR object - represents a not-a-number value (as opposed to whether this object - does not express a number). - true if this CBOR object represents a not-a-number - value (as opposed to whether this object does not represent a - number as defined by the IsNumber property or isNumber() - method in Java); otherwise, false. - - - Gets a value indicating whether this CBOR object - represents negative infinity. - true if this CBOR object represents negative - infinity; otherwise, false. - - - Gets a value indicating whether this CBOR object - represents positive infinity. - true if this CBOR object represents positive - infinity; otherwise, false. - - - Gets this object's value with the sign reversed. - The reversed-sign form of this number. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - - - Removes all items from this CBOR array or all keys and - values from this CBOR map. - This object is not a - CBOR array or CBOR map. - - - If this object is an array, removes the first instance of - the specified item (once converted to a CBOR object) from the - array. If this object is a map, removes the item with the given key - (once converted to a CBOR object) from the map. - The item or key (once converted to a CBOR object) - to remove. - true if the item was removed; otherwise, - false. - The parameter is null (as opposed to CBORObject.Null). - The object is not an - array or map. - - - Removes the item at the given index of this CBOR - array. - The index, starting at 0, of the item to - remove. - Returns "true" if the object was removed. Returns "false" - if the given index is less than 0, or is at least as high as the - number of items in the array. - This object is not a - CBOR array. - - - If this object is an array, removes the first instance of - the specified item from the array. If this object is a map, removes - the item with the given key from the map. - The item or key to remove. - true if the item was removed; otherwise, - false. - The parameter is null (as opposed to CBORObject.Null). - The object is not an - array or map. - - - Maps an object to a key in this CBOR map, or adds the - value if the key doesn't exist. If this is a CBOR array, instead - sets the value at the given index to the given value. - If this instance is a CBOR map, this parameter is - an object representing the key, which will be converted to a - CBORObject; in this case, this parameter can be null, in which case - this value is converted to CBORObject.Null. If this instance is a - CBOR array, this parameter must be a 32-bit signed integer( - int ) identifying the index (starting from 0) of the item to - set in the array. - An object representing the value, which will - be converted to a CBORObject. Can be null, in which case this value - is converted to CBORObject.Null. - This instance. - This object is not a - map or an array. - The parameter or has an unsupported type, - or this instance is a CBOR array and is less - than 0, is the size of this array or greater, or is not a 32-bit - signed integer ( int ). - - - Converts this object to a text string in JavaScript Object - Notation (JSON) format. See the overload to ToJSONString taking a - JSONOptions argument for further information. - If the CBOR object contains CBOR maps, or is a CBOR map - itself, the order in which the keys to the map are written out to - the JSON string is undefined unless the map was created using the - NewOrderedMap method. Map keys other than untagged text strings are - converted to JSON strings before writing them out (for example, - 22("Test") is converted to "Test" and true is - converted to "true" ). After such conversion, if two or more - keys for the same map are identical, this method throws a - CBORException. The example code given in - PeterO.Cbor.CBORObject.ToJSONString(PeterO.Cbor.JSONOptions) - can be used to write out certain keys of a CBOR map in a given - order to a JSON string, or to write out a CBOR object as part of a - JSON text sequence. - Warning: In general, if this CBOR object contains - integer map keys or uses other features not supported in JSON, and - the application converts this CBOR object to JSON and back to CBOR, - the application - should not expect the new CBOR object to be exactly the same - as the original. This is because the conversion in many cases may - have to convert unsupported features in JSON to supported features - which correspond to a different feature in CBOR (such as converting - integer map keys, which are supported in CBOR but not JSON, to text - strings, which are supported in both). - A text string containing the converted object in JSON - format. - - - - Converts this object to a text string in JavaScript - Object Notation (JSON) format, using the specified - options to control the encoding process. This function - works not only with arrays and maps, but also integers, - strings, byte arrays, and other JSON data types. Notes: - - If this object contains maps with non-string - keys, the keys are converted to JSON strings before writing the map - as a JSON string. - If this object represents a number - (the IsNumber property, or isNumber() method in Java, returns - true), then it is written out as a number. - If the CBOR - object contains CBOR maps, or is a CBOR map itself, the order in - which the keys to the map are written out to the JSON string is - undefined unless the map was created using the NewOrderedMap - method. Map keys other than untagged text strings are converted to - JSON strings before writing them out (for example, - 22("Test") - is converted to "Test" - and true - is - converted to "true" - ). After such conversion, if two or more - keys for the same map are identical, this method throws a - CBORException. - If a number in the form of an - arbitrary-precision binary floating-point number has a very high - binary exponent, it will be converted to a double before being - converted to a JSON string. (The resulting double could overflow to - infinity, in which case the arbitrary-precision binary - floating-point number is converted to null.) - The - string will not begin with a byte-order mark (U+FEFF); RFC 8259 - (the JSON specification) forbids placing a byte-order mark at the - beginning of a JSON string. - Byte strings are converted - to Base64 URL without whitespace or padding by default (see section - 3.4.5.3 of RFC 8949). A byte string will instead be converted to - traditional base64 without whitespace and with padding if it has - tag 22, or base16 for tag 23. (To create a CBOR object with a given - tag, call the CBORObject.FromObjectAndTag - method and pass - the CBOR object and the desired tag number to that method.) - Rational numbers will be converted to their exact form, if - possible, otherwise to a high-precision approximation. (The - resulting approximation could overflow to infinity, in which case - the rational number is converted to null.) - Simple - values other than true and false will be converted to null. (This - doesn't include floating-point numbers.) - Infinity and - not-a-number will be converted to null. - - Warning: - In general, if this CBOR object contains - integer map keys or uses other features not supported in JSON, and - the application converts this CBOR object to JSON and back to CBOR, - the application should not - expect the new CBOR object to be - exactly the same as the original. This is because the conversion in - many cases may have to convert unsupported features in JSON to - supported features which correspond to a different feature in CBOR - (such as converting integer map keys, which are supported in CBOR - but not JSON, to text strings, which are supported in both). - The example code given below (originally written in C# for - the.NET version) can be used to write out certain keys of a CBOR - map in a given order to a JSON string. - /* Generates a JSON string of 'mapObj' whose keys are in the order - given - in 'keys' . Only keys found in 'keys' will be written if they exist in - 'mapObj'. */ private static string KeysToJSONMap(CBORObject mapObj, - IList<CBORObject> keys) { if (mapObj == null) { throw new - ArgumentNullException)nameof(mapObj));} - if (keys == null) { throw new - ArgumentNullException)nameof(keys));} - if (obj.Type != CBORType.Map) { - throw new ArgumentException("'obj' is not a map."); } StringBuilder - builder = new StringBuilder(); var first = true; builder.Append("{"); - for (CBORObject key in keys) { if (mapObj.ContainsKey(key)) { if - (!first) {builder.Append(", ");} var keyString=(key.CBORType == - CBORType.String) ? key.AsString() : key.ToJSONString(); - builder.Append(CBORObject.FromObject(keyString) .ToJSONString()) - .Append(":").Append(mapObj[key].ToJSONString()); first=false; } } return - builder.Append("}").ToString(); } - . - - Specifies options to control writing the CBOR - object to JSON. - A text string containing the converted object in JSON - format. - The parameter is null. - - - Returns this CBOR object in a text form intended to be - read by humans. The value returned by this method is not intended - to be parsed by computer programs, and the exact text of the value - may change at any time between versions of this library. - The returned string is not necessarily in JavaScript Object - Notation (JSON); to convert CBOR objects to JSON strings, use the - PeterO.Cbor.CBORObject.ToJSONString(PeterO.Cbor.JSONOptions) - method instead. - A text representation of this object. - - - Gets an object with the same value as this one but without - the tags it has, if any. If this object is an array, map, or byte - string, the data will not be copied to the returned object, so - changes to the returned object will be reflected in this - one. - A CBOR object. - - - Gets an object with the same value as this one but without - this object's outermost tag, if any. If this object is an array, - map, or byte string, the data will not be copied to the returned - object, so changes to the returned object will be reflected in this - one. - A CBOR object. - - - Converts this object to a text string in JavaScript Object - Notation (JSON) format, as in the ToJSONString method, and writes - that string to a data stream in UTF-8. If the CBOR object contains - CBOR maps, or is a CBOR map, the order in which the keys to the map - are written out to the JSON string is undefined unless the map was - created using the NewOrderedMap method. The example code given in - PeterO.Cbor.CBORObject.ToJSONString(PeterO.Cbor.JSONOptions) - can be used to write out certain keys of a CBOR map in a given - order to a JSON string. - A writable data stream. - An I/O error - occurred. - The parameter is null. - - The following example (originally written in C# for the.NET - version) writes out a CBOR object as part of a JSON text sequence - (RFC 7464). - - stream.WriteByte(0x1e); /* RS */ - cborObject.WriteJSONTo(stream); /* JSON */ - stream.WriteByte(0x0a); /* LF */ - - The following example (originally written in C# for the.NET - version) shows how to use the LimitedMemoryStream - class - (implemented in LimitedMemoryStream.cs - in the peteroupc/CBOR - open-source repository) to limit the size of supported JSON - serializations of CBOR objects. - - /* maximum supported JSON size in bytes*/ - var maxSize = 20000; - using (var ms = new LimitedMemoryStream(maxSize)) { - cborObject.WriteJSONTo(ms); - var bytes = ms.ToArray(); - } - - The following example (written in Java for the Java version) - shows how to use a subclassed OutputStream - together with a - ByteArrayOutputStream - to limit the size of supported JSON - serializations of CBOR objects. - - /* maximum supported JSON size in bytes*/ - final int maxSize = 20000; - ByteArrayOutputStream ba = new ByteArrayOutputStream(); - /* throws UnsupportedOperationException if too big*/ - cborObject.WriteJSONTo(new FilterOutputStream(ba) { - private int size = 0; - public void write(byte[] b, int off, int len) throws IOException { - if (len>(maxSize-size)) { - throw new UnsupportedOperationException(); - } - size+=len; out.write(b, off, len); - } - public void write(byte b) throws IOException { - if (size >= maxSize) { - throw new UnsupportedOperationException(); - } - size++; out.write(b); - } - }); - byte[] bytes = ba.toByteArray(); - - The following example (originally written in C# for the.NET - version) shows how to use a.NET MemoryStream to limit the size of - supported JSON serializations of CBOR objects. The disadvantage is - that the extra memory needed to do so can be wasteful, especially - if the average serialized object is much smaller than the maximum - size given (for example, if the maximum size is 20000 bytes, but - the average serialized object has a size of 50 bytes). - - var backing = new byte[20000]; /* maximum supported JSON size in - bytes*/ - byte[] bytes1, bytes2; - using (var ms = new MemoryStream(backing)) { - /* throws NotSupportedException if too big*/ - cborObject.WriteJSONTo(ms); - bytes1 = new byte[ms.Position]; - /* Copy serialized data if successful*/ - System.ArrayCopy(backing, 0, bytes1, 0, (int)ms.Position); - /* Reset memory stream*/ - ms.Position = 0; - cborObject2.WriteJSONTo(ms); - bytes2 = new byte[ms.Position]; - /* Copy serialized data if successful*/ - System.ArrayCopy(backing, 0, bytes2, 0, (int)ms.Position); - } - - - - - Converts this object to a text string in JavaScript Object - Notation (JSON) format, as in the ToJSONString method, and writes - that string to a data stream in UTF-8, using the given JSON options - to control the encoding process. If the CBOR object contains CBOR - maps, or is a CBOR map, the order in which the keys to the map are - written out to the JSON string is undefined unless the map was - created using the NewOrderedMap method. The example code given in - PeterO.Cbor.CBORObject.ToJSONString(PeterO.Cbor.JSONOptions) - can be used to write out certain keys of a CBOR map in a given - order to a JSON string. - A writable data stream. - An object containing the options to control - writing the CBOR object to JSON. - An I/O error - occurred. - The parameter is null. - - - Generates a CBOR object from a floating-point number - represented by its bits. - The bits of a floating-point number - number to write. - The number of bytes of the stored - floating-point number; this also specifies the format of the - "floatingBits" parameter. This value can be 2 if "floatingBits"'s - lowest (least significant) 16 bits identify the floating-point - number in IEEE 754r binary16 format; or 4 if "floatingBits"'s - lowest (least significant) 32 bits identify the floating-point - number in IEEE 754r binary32 format; or 8 if "floatingBits" - identifies the floating point number in IEEE 754r binary64 format. - Any other values for this parameter are invalid. - A CBOR object storing the given floating-point - number. - The parameter is other than 2, 4, or 8. - - - Writes the bits of a floating-point number in CBOR format - to a data stream. - A writable data stream. - The bits of a floating-point number - number to write. - The number of bytes of the stored - floating-point number; this also specifies the format of the - "floatingBits" parameter. This value can be 2 if "floatingBits"'s - lowest (least significant) 16 bits identify the floating-point - number in IEEE 754r binary16 format; or 4 if "floatingBits"'s - lowest (least significant) 32 bits identify the floating-point - number in IEEE 754r binary32 format; or 8 if "floatingBits" - identifies the floating point number in IEEE 754r binary64 format. - Any other values for this parameter are invalid. This method will - write one plus this many bytes to the data stream. - The number of 8-bit bytes ordered to be written to the - data stream. - The parameter is other than 2, 4, or 8. - The parameter is null. - - - Writes the bits of a floating-point number in CBOR format - to a data stream. - A writable data stream. - The bits of a floating-point number - number to write. - The number of bytes of the stored - floating-point number; this also specifies the format of the - "floatingBits" parameter. This value can be 2 if "floatingBits"'s - lowest (least significant) 16 bits identify the floating-point - number in IEEE 754r binary16 format; or 4 if "floatingBits"'s - lowest (least significant) 32 bits identify the floating-point - number in IEEE 754r binary32 format; or 8 if "floatingBits" - identifies the floating point number in IEEE 754r binary64 format. - Any other values for this parameter are invalid. - If true, writes the shortest form of the - floating-point number that preserves its value. If false, this - method will write the number in the form given by 'floatingBits' by - writing one plus the number of bytes given by 'byteCount' to the - data stream. - The number of 8-bit bytes ordered to be written to the - data stream. - The parameter is other than 2, 4, or 8. - The parameter is null. - - - Writes a 64-bit binary floating-point number in CBOR - format to a data stream, either in its 64-bit form, or its rounded - 32-bit or 16-bit equivalent. - A writable data stream. - The double-precision floating-point number - to write. - The number of 8-bit bytes of the stored - number. This value can be 2 to store the number in IEEE 754r - binary16, rounded to nearest, ties to even; or 4 to store the - number in IEEE 754r binary32, rounded to nearest, ties to even; or - 8 to store the number in IEEE 754r binary64. Any other values for - this parameter are invalid. - The number of 8-bit bytes ordered to be written to the - data stream. - The parameter is other than 2, 4, or 8. - The parameter is null. - - - Writes a 32-bit binary floating-point number in CBOR - format to a data stream, either in its 64- or 32-bit form, or its - rounded 16-bit equivalent. - A writable data stream. - The single-precision floating-point number - to write. - The number of 8-bit bytes of the stored - number. This value can be 2 to store the number in IEEE 754r - binary16, rounded to nearest, ties to even; or 4 to store the - number in IEEE 754r binary32; or 8 to store the number in IEEE 754r - binary64. Any other values for this parameter are invalid. - The number of 8-bit bytes ordered to be written to the - data stream. - The parameter is other than 2, 4, or 8. - The parameter is null. - - - Writes a CBOR major type number and an integer 0 or - greater associated with it to a data stream, where that integer is - passed to this method as a 64-bit signed integer. This is a - low-level method that is useful for implementing custom CBOR - encoding methodologies. This method encodes the given major type - and value in the shortest form allowed for the major - type. - A writable data stream. - The CBOR major type to write. This is a - number from 0 through 7 as follows. 0: integer 0 or greater; 1: - negative integer; 2: byte string; 3: UTF-8 text string; 4: array; - 5: map; 6: tag; 7: simple value. See RFC 8949 for details on these - major types. - An integer 0 or greater associated with the - major type, as follows. 0: integer 0 or greater; 1: the negative - integer's absolute value is 1 plus this number; 2: length in bytes - of the byte string; 3: length in bytes of the UTF-8 text string; 4: - number of items in the array; 5: number of key-value pairs in the - map; 6: tag number; 7: simple value number, which must be in the - interval [0, 23] or [32, 255]. - The number of bytes ordered to be written to the data - stream. - Value is from 24 to 31 and - major type is 7. - The parameter is null. - There are other useful things to note when encoding CBOR - that are not covered by this WriteValue method. To mark the start - of an indefinite-length array, write the 8-bit byte 0x9f to the - output stream. To mark the start of an indefinite-length map, write - the 8-bit byte 0xbf to the output stream. To mark the end of an - indefinite-length array or map, write the 8-bit byte 0xff to the - output stream. For examples, see the WriteValue(Stream, int, int) - overload. - - - Writes a CBOR major type number and an integer 0 or - greater associated with it to a data stream, where that integer is - passed to this method as a 32-bit signed integer. This is a - low-level method that is useful for implementing custom CBOR - encoding methodologies. This method encodes the given major type - and value in the shortest form allowed for the major - type. - A writable data stream. - The CBOR major type to write. This is a - number from 0 through 7 as follows. 0: integer 0 or greater; 1: - negative integer; 2: byte string; 3: UTF-8 text string; 4: array; - 5: map; 6: tag; 7: simple value. See RFC 8949 for details on these - major types. - An integer 0 or greater associated with the - major type, as follows. 0: integer 0 or greater; 1: the negative - integer's absolute value is 1 plus this number; 2: length in bytes - of the byte string; 3: length in bytes of the UTF-8 text string; 4: - number of items in the array; 5: number of key-value pairs in the - map; 6: tag number; 7: simple value number, which must be in the - interval [0, 23] or [32, 255]. - The number of bytes ordered to be written to the data - stream. - Value is from 24 to 31 and - major type is 7. - The parameter is null. - There are other useful things to note when encoding CBOR - that are not covered by this WriteValue method. To mark the start - of an indefinite-length array, write the 8-bit byte 0x9f to the - output stream. To mark the start of an indefinite-length map, write - the 8-bit byte 0xbf to the output stream. To mark the end of an - indefinite-length array or map, write the 8-bit byte 0xff to the - output stream. - - In the following example, an array of three objects is - written as CBOR to a data stream. - /* array, length 3*/ - CBORObject.WriteValue(stream, 4, 3); - /* item 1 */ - CBORObject.Write("hello world", stream); - CBORObject.Write(25, stream); /* item 2*/ - CBORObject.Write(false, stream); /* item 3*/ - In the following example, a map consisting of two key-value - pairs is written as CBOR to a data stream. - CBORObject.WriteValue(stream, 5, 2); /* map, 2 - pairs*/ - CBORObject.Write("number", stream); /* key 1 */ - CBORObject.Write(25, stream); /* value 1 */ - CBORObject.Write("string", stream); /* key 2*/ - CBORObject.Write("hello", stream); /* value 2*/ - In the following example (originally written in C# for - the.NET Framework version), a text string is written as CBOR to a - data stream. - string str = "hello world"; byte[] bytes = - DataUtilities.GetUtf8Bytes(str, true); CBORObject.WriteValue(stream, 4, - bytes.Length); stream.Write(bytes, 0, bytes.Length); - . - - - - Writes a CBOR major type number and an integer 0 or - greater associated with it to a data stream, where that integer is - passed to this method as an arbitrary-precision integer. This is a - low-level method that is useful for implementing custom CBOR - encoding methodologies. This method encodes the given major type - and value in the shortest form allowed for the major - type. - A writable data stream. - The CBOR major type to write. This is a - number from 0 through 7 as follows. 0: integer 0 or greater; 1: - negative integer; 2: byte string; 3: UTF-8 text string; 4: array; - 5: map; 6: tag; 7: simple value. See RFC 8949 for details on these - major types. - An integer 0 or greater associated with - the major type, as follows. 0: integer 0 or greater; 1: the - negative integer's absolute value is 1 plus this number; 2: length - in bytes of the byte string; 3: length in bytes of the UTF-8 text - string; 4: number of items in the array; 5: number of key-value - pairs in the map; 6: tag number; 7: simple value number, which must - be in the interval [0, 23] or [32, 255]. For major types 0 to 6, - this number may not be greater than 2^64 - 1. - The number of bytes ordered to be written to the data - stream. - The parameter is 7 and value is greater than 255. - The parameter or is - null. - There are other useful things to note when encoding CBOR - that are not covered by this WriteValue method. To mark the start - of an indefinite-length array, write the 8-bit byte 0x9f to the - output stream. To mark the start of an indefinite-length map, write - the 8-bit byte 0xbf to the output stream. To mark the end of an - indefinite-length array or map, write the 8-bit byte 0xff to the - output stream. - - - Writes this CBOR object to a data stream. If the - CBOR object contains CBOR maps, or is a CBOR map, the order in - which the keys to the map are written out to the data stream is - undefined unless the map was created using the NewOrderedMap - method. See the examples (originally written in C# for the.NET - version) for ways to write out certain keys of a CBOR map in a - given order. In the case of CBOR objects of type FloatingPoint, the - number is written using the shortest floating-point encoding - possible; this is a change from previous versions. - - A writable data stream. - The parameter is null. - An I/O error - occurred. - - The following example shows a method that writes each key of - 'mapObj' to 'outputStream', in the order given in 'keys', where - 'mapObj' is written out in the form of a CBOR definite-length - map - . Only keys found in 'keys' will be written if they exist - in 'mapObj'. - private static void WriteKeysToMap(CBORObject mapObj, - IList<CBORObject> keys, Stream outputStream) { - if (mapObj == null) { - throw new ArgumentNullException(nameof(mapObj));} - if (keys == null) - {throw new ArgumentNullException(nameof(keys));} - if (outputStream == - null) {throw new ArgumentNullException(nameof(outputStream));} - if - (obj.Type!=CBORType.Map) { throw new ArgumentException("'obj' is not a - map."); } int keyCount = 0; for (CBORObject key in keys) { if - (mapObj.ContainsKey(key)) { keyCount++; } } - CBORObject.WriteValue(outputStream, 5, keyCount); for (CBORObject key in - keys) { if (mapObj.ContainsKey(key)) { key.WriteTo(outputStream); - mapObj[key].WriteTo(outputStream); } } } - The following example shows a method that writes each key of - 'mapObj' to 'outputStream', in the order given in 'keys', where - 'mapObj' is written out in the form of a CBOR indefinite-length - map - . Only keys found in 'keys' will be written if they exist - in 'mapObj'. - private static void WriteKeysToIndefMap(CBORObject mapObj, - IList<CBORObject> keys, Stream outputStream) { if (mapObj == null) - { throw new ArgumentNullException(nameof(mapObj));} - if (keys == null) - {throw new ArgumentNullException(nameof(keys));} - if (outputStream == - null) {throw new ArgumentNullException(nameof(outputStream));} - if - (obj.Type!=CBORType.Map) { throw new ArgumentException("'obj' is not a - map."); } outputStream.WriteByte((byte)0xBF); for (CBORObject key in - keys) { if (mapObj.ContainsKey(key)) { key.WriteTo(outputStream); - mapObj[key].WriteTo(outputStream); } } - outputStream.WriteByte((byte)0xff); } - The following example shows a method that writes out a list - of objects to 'outputStream' as an indefinite-length CBOR - array - . - private static void WriteToIndefArray(IList<object> list, - Stream - outputStream) { if (list == null) { throw new - ArgumentNullException(nameof(list));} - if (outputStream == null) {throw - new ArgumentNullException(nameof(outputStream));} - outputStream.WriteByte((byte)0x9f); for (object item in list) { new - CBORObject(item).WriteTo(outputStream); } - outputStream.WriteByte((byte)0xff); } - The following example (originally written in C# for the.NET - version) shows how to use the LimitedMemoryStream - class - (implemented in LimitedMemoryStream.cs - in the peteroupc/CBOR - open-source repository) to limit the size of supported CBOR - serializations. - - /* maximum supported CBOR size in bytes*/ - var maxSize = 20000; - using (var ms = new LimitedMemoryStream(maxSize)) { - cborObject.WriteTo(ms); - var bytes = ms.ToArray(); - } - - The following example (written in Java for the Java version) - shows how to use a subclassed OutputStream - together with a - ByteArrayOutputStream - to limit the size of supported CBOR - serializations. - - /* maximum supported CBOR size in bytes*/ - final int maxSize = 20000; - ByteArrayOutputStream ba = new ByteArrayOutputStream(); - /* throws UnsupportedOperationException if too big*/ - cborObject.WriteTo(new FilterOutputStream(ba) { - private int size = 0; - public void write(byte[] b, int off, int len) throws IOException { - if (len>(maxSize-size)) { - throw new UnsupportedOperationException(); - } - size+=len; out.write(b, off, len); - } - public void write(byte b) throws IOException { - if (size >= maxSize) { - throw new UnsupportedOperationException(); - } - size++; out.write(b); - } - }); - byte[] bytes = ba.toByteArray(); - - The following example (originally written in C# for the.NET - version) shows how to use a.NET MemoryStream to limit the size of - supported CBOR serializations. The disadvantage is that the extra - memory needed to do so can be wasteful, especially if the average - serialized object is much smaller than the maximum size given (for - example, if the maximum size is 20000 bytes, but the average - serialized object has a size of 50 bytes). - - var backing = new byte[20000]; /* maximum supported CBOR size in - bytes*/ - byte[] bytes1, bytes2; - using (var ms = new MemoryStream(backing)) { - /* throws NotSupportedException if too big*/ - cborObject.WriteTo(ms); - bytes1 = new byte[ms.Position]; - /* Copy serialized data if successful*/ - System.ArrayCopy(backing, 0, bytes1, 0, (int)ms.Position); - /* Reset memory stream*/ - ms.Position = 0; - cborObject2.WriteTo(ms); - bytes2 = new byte[ms.Position]; - /* Copy serialized data if successful*/ - System.ArrayCopy(backing, 0, bytes2, 0, (int)ms.Position); - } - - - - - Writes this CBOR object to a data stream, using the - specified options for encoding the data to CBOR format. If the CBOR - object contains CBOR maps, or is a CBOR map, the order in which the - keys to the map are written out to the data stream is undefined - unless the map was created using the NewOrderedMap method. The - example code given in - can - be used to write out certain keys of a CBOR map in a given order. - In the case of CBOR objects of type FloatingPoint, the number is - written using the shortest floating-point encoding possible; this - is a change from previous versions. - A writable data stream. - Options for encoding the data to - CBOR. - The parameter is null. - An I/O error - occurred. - Unexpected data - type". - - - Returns whether one object's value is less than - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is less than another's; - otherwise, false. - The parameter is null. - - - Returns whether one object's value is up to - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is up to another's; - otherwise, false. - The parameter is null. - - - Returns whether one object's value is greater than - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is greater than - another's; otherwise, false. - The parameter is null. - - - Returns whether one object's value is at least - another's. - The left-hand side of the comparison. - The right-hand side of the comparison. - true if one object's value is at least another's; - otherwise, false. - The parameter is null. - - - Converts this object to a 16-bit unsigned integer after - discarding any fractional part, if any, from its value. - A 16-bit unsigned integer. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value, if - converted to an integer by discarding its fractional part, is - outside the range of a 16-bit unsigned integer. - - - Converts this object to a 32-bit unsigned integer after - discarding any fractional part, if any, from its value. - A 32-bit unsigned integer. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value, if - converted to an integer by discarding its fractional part, is - outside the range of a 32-bit unsigned integer. - - - Converts this object to an 8-bit signed integer. - An 8-bit signed integer. - - - Writes a CBOR major type number and an integer 0 or - greater associated with it to a data stream, where that integer is - passed to this method as a 32-bit unsigned integer. This is a - low-level method that is useful for implementing custom CBOR - encoding methodologies. This method encodes the given major type - and value in the shortest form allowed for the major - type. - A writable data stream. - The CBOR major type to write. This is a - number from 0 through 7 as follows. 0: integer 0 or greater; 1: - negative integer; 2: byte string; 3: UTF-8 text string; 4: array; - 5: map; 6: tag; 7: simple value. See RFC 7049 for details on these - major types. - An integer 0 or greater associated with the - major type, as follows. 0: integer 0 or greater; 1: the negative - integer's absolute value is 1 plus this number; 2: length in bytes - of the byte string; 3: length in bytes of the UTF-8 text string; 4: - number of items in the array; 5: number of key-value pairs in the - map; 6: tag number; 7: simple value number, which must be in the - interval [0, 23] or [32, 255]. - The number of bytes ordered to be written to the data - stream. - The parameter is null. - - - Writes a CBOR major type number and an integer 0 or - greater associated with it to a data stream, where that integer is - passed to this method as a 64-bit unsigned integer. This is a - low-level method that is useful for implementing custom CBOR - encoding methodologies. This method encodes the given major type - and value in the shortest form allowed for the major - type. - A writable data stream. - The CBOR major type to write. This is a - number from 0 through 7 as follows. 0: integer 0 or greater; 1: - negative integer; 2: byte string; 3: UTF-8 text string; 4: array; - 5: map; 6: tag; 7: simple value. See RFC 7049 for details on these - major types. - An integer 0 or greater associated with the - major type, as follows. 0: integer 0 or greater; 1: the negative - integer's absolute value is 1 plus this number; 2: length in bytes - of the byte string; 3: length in bytes of the UTF-8 text string; 4: - number of items in the array; 5: number of key-value pairs in the - map; 6: tag number; 7: simple value number, which must be in the - interval [0, 23] or [32, 255]. - The number of bytes ordered to be written to the data - stream. - The parameter is 7 and value is greater than 255. - The parameter is null. - - - Converts this object to a DotNet decimal. - The closest big integer to this object. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value exceeds the - range of a DotNet decimal. - - - Converts this object to a 64-bit unsigned integer after - discarding any fractional part, if any, from its value. - A 64-bit unsigned integer. - This object does not - represent a number (for this purpose, infinities and not-a-number - or NaN values, but not CBORObject.Null, are considered - numbers). - This object's value, if - converted to an integer by discarding its fractional part, is - outside the range of a 64-bit unsigned integer. - - - Writes an 8-bit signed integer in CBOR format to a data - stream. - The parameter is an - 8-bit signed integer. - A writable data stream. - - - Writes a 64-bit unsigned integer in CBOR format to a data - stream. - A 64-bit unsigned integer. - A writable data stream. - The parameter is null. - - - Converts a.NET decimal to a CBOR object. - The parameter is a - Decimal object. - A CBORObject object with the same value as the.NET - decimal. - - - Writes a 32-bit unsigned integer in CBOR format to a data - stream. - A 32-bit unsigned integer. - A writable data stream. - - - Writes a 16-bit unsigned integer in CBOR format to a data - stream. - A 16-bit unsigned integer. - A writable data stream. - - - Converts a signed 8-bit integer to a CBOR - object. - The parameter is an - 8-bit signed integer. - A CBORObject object. - - - Converts a 64-bit unsigned integer to a CBOR - object. - A 64-bit unsigned integer. - A CBORObject object. - - - Converts a 32-bit unsigned integer to a CBOR - object. - A 32-bit unsigned integer. - A CBORObject object. - - - Converts a 16-bit unsigned integer to a CBOR - object. - A 16-bit unsigned integer. - A CBORObject object. - - - Generates a CBOR object from this one, but gives the - resulting object a tag in addition to its existing tags (the new - tag is made the outermost tag). - A 64-bit integer that specifies a tag number. The - tag number 55799 can be used to mark a "self-described CBOR" - object. This document does not attempt to list all CBOR tags and - their meanings. An up-to-date list can be found at the CBOR Tags - registry maintained by the Internet Assigned Numbers Authority( - iana.org/assignments/cbor-tags ). - A CBOR object with the same value as this one but given - the tag in addition to its existing tags - (the new tag is made the outermost tag). - - - Generates a CBOR object from an arbitrary object and gives - the resulting object a tag. - The parameter is an arbitrary - object, which can be null. - NOTE: For security reasons, whenever possible, an - application should not base this parameter on user input or other - externally supplied data unless the application limits this - parameter's inputs to types specially handled by this method (such - as int or String ) and/or to plain-old-data types - (POCO or POJO types) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above.. - A 64-bit integer that specifies a tag number. The - tag number 55799 can be used to mark a "self-described CBOR" - object. This document does not attempt to list all CBOR tags and - their meanings. An up-to-date list can be found at the CBOR Tags - registry maintained by the Internet Assigned Numbers Authority( - iana.org/assignments/cbor-tags ). - A CBOR object where the object is - converted to a CBOR object and given the tag - . If "valueOb" is null, returns a version of CBORObject.Null with - the given tag. - - - - Converts this CBOR object to an object of an arbitrary type. - See - for - further information. - The type, class, or interface that this - method's return value will belong to. Note: For security - reasons, an application should not base this parameter on user - input or other externally supplied data. Whenever possible, this - parameter should be either a type specially handled by this method - (such as int or String ) or a plain-old-data type - (POCO or POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - The converted object. - The given type "T", or this - object's CBOR type, is not supported. - - - - Converts this CBOR object to an object of an arbitrary type. - See - for - further information. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. - The type, class, or interface that this - method's return value will belong to. Note: For security - reasons, an application should not base this parameter on user - input or other externally supplied data. Whenever possible, this - parameter should be either a type specially handled by this method - (such as int or String ) or a plain-old-data type - (POCO or POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - The converted object. - The given type "T", or this - object's CBOR type, is not supported. - - - - Converts this CBOR object to an object of an arbitrary type. - See - for - further information. - Specifies options for controlling - deserialization of CBOR objects. - The type, class, or interface that this - method's return value will belong to. Note: For security - reasons, an application should not base this parameter on user - input or other externally supplied data. Whenever possible, this - parameter should be either a type specially handled by this method - (such as int or String ) or a plain-old-data type - (POCO or POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - The converted object. - The given type "T", or this - object's CBOR type, is not supported. - - - - Converts this CBOR object to an object of an arbitrary type. - See - for - further information. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. - Specifies options for controlling - deserialization of CBOR objects. - The type, class, or interface that this - method's return value will belong to. Note: For security - reasons, an application should not base this parameter on user - input or other externally supplied data. Whenever possible, this - parameter should be either a type specially handled by this method - (such as int or String ) or a plain-old-data type - (POCO or POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - The converted object. - The given type "T", or this - object's CBOR type, is not supported. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes, using the given CBOREncodeOptions object - to control the decoding process. It is equivalent to - DecodeFromBytes followed by ToObject. See the documentation for - those methods for more information. - A byte array in which a single CBOR object is - encoded. - Specifies options to control how the CBOR object - is decoded. See - for more - information. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. Can be - null. - Specifies options for controlling deserialization - of CBOR objects. - The type, class, or interface that this - method's return value will belong to. To express a generic type in - Java, see the example. Note: For security reasons, an - application should not base this parameter on user input or other - externally supplied data. Whenever possible, this parameter should - be either a type specially handled by this method, such as - int or String, or a plain-old-data type (POCO or - POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type "T", or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter is null, or the parameter is - null, or the parameter "T" or is - null. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes, using the given CBOREncodeOptions object - to control the decoding process. It is equivalent to - DecodeFromBytes followed by ToObject. See the documentation for - those methods for more information. - A byte array in which a single CBOR object is - encoded. - Specifies options to control how the CBOR object - is decoded. See - for more - information. - The type, class, or interface that this - method's return value will belong to. Note: For security - reasons, an application should not base this parameter on user - input or other externally supplied data. Whenever possible, this - parameter should be either a type specially handled by this method, - such as int or String, or a plain-old-data type - (POCO or POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type "T", or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter is null, or the parameter is - null. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes. It is equivalent to DecodeFromBytes followed by - ToObject. See the documentation for those methods for more - information. - A byte array in which a single CBOR object is - encoded. - This parameter controls which data types are - eligible for Plain-Old-Data deserialization and includes custom - converters from CBOR objects to certain data types. Can be - null. - Specifies options for controlling deserialization - of CBOR objects. - The type, class, or interface that this - method's return value will belong to. To express a generic type in - Java, see the example. Note: For security reasons, an - application should not base this parameter on user input or other - externally supplied data. Whenever possible, this parameter should - be either a type specially handled by this method, such as - int or String, or a plain-old-data type (POCO or - POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type "T", or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter is null, or the parameter "T" or is null. - - - Generates an object of an arbitrary type from an array of - CBOR-encoded bytes. It is equivalent to DecodeFromBytes followed by - ToObject. See the documentation for those methods for more - information. - A byte array in which a single CBOR object is - encoded. - The type, class, or interface that this - method's return value will belong to. To express a generic type in - Java, see the example. Note: For security reasons, an - application should not base this parameter on user input or other - externally supplied data. Whenever possible, this parameter should - be either a type specially handled by this method, such as - int or String, or a plain-old-data type (POCO or - POJO type) within the control of the application. If the - plain-old-data type references other data types, those types should - likewise meet either criterion above. - An object of the given type decoded from the given byte - array. Returns null (as opposed to CBORObject.Null) if is empty and the AllowEmpty property is set on the - given CBOREncodeOptions object. - There was an error in - reading or parsing the data. This includes cases where not all of - the byte array represents a CBOR object. This exception is also - thrown if the parameter is empty unless the - AllowEmpty property is set on the given options object. Also thrown - if the given type "T", or this object's CBOR type, is not - supported, or the given object's nesting is too deep, or another - error occurred when serializing the object. - The parameter is null. - - - Does an addition on two CBOR objects and returns their - result. - The parameter is a CBOR - object. - The parameter is a CBOR - object. - The sum of the two objects. - - - Subtracts a CBORObject object from a CBORObject - object. - The parameter is a CBOR - object. - The parameter is a CBOR - object. - The difference of the two objects. - - - Multiplies a CBORObject object by the value of a - CBORObject object. - The parameter is a CBOR - object. - The parameter is a CBOR - object. - The product of the two numbers. - - - Divides a CBORObject object by the value of a CBORObject - object. - The parameter is a CBOR - object. - The parameter is a CBOR - object. - The quotient of the two objects. - - - Finds the remainder that results when a CBORObject object - is divided by the value of a CBORObject object. - The parameter is a CBOR - object. - The parameter is a CBOR - object. - The remainder of the two numbers. - - - Represents a type that a CBOR object can have. - - - This property is no longer used. - - - The simple values true and false. - - - A "simple value" other than floating point values, true, - and false. - - - An array of bytes. - - - A text string. - - - An array of CBOR objects. - - - A map of CBOR objects. - - - An integer in the interval [-(2^64), 2^64 - 1], or an - integer of major type 0 and 1. - - - A 16-, 32-, or 64-bit binary floating-point - number. - - - Holds converters to customize the serialization and - deserialization behavior of CBORObject.FromObject and - CBORObject#ToObject, as well as type filters for - ToObject. - - - Initializes a new instance of the - class. - - - Registers an object that converts objects of a given type - to CBOR objects (called a CBOR converter). If the CBOR converter - converts to and from CBOR objects, it should implement the - ICBORToFromConverter interface and provide ToCBORObject and - FromCBORObject methods. If the CBOR converter only supports - converting to (not from) CBOR objects, it should implement the - ICBORConverter interface and provide a ToCBORObject - method. - A Type object specifying the type that the - converter converts to CBOR objects. - The parameter - is an ICBORConverter object. - Must be the same as the "type" - parameter. - This object. - The parameter or is null. - Converter doesn't contain a - proper ToCBORObject method". - - - Returns whether the given Java or.NET type name fits the - filters given in this mapper. - The fully qualified name of a Java or.NET - class (e.g., java.math.BigInteger or - System.Globalization.CultureInfo ). - Either true if the given Java or.NET type name fits - the filters given in this mapper, or false - otherwise. - - - Adds a prefix of a Java or.NET type for use in type - matching. A type matches a prefix if its fully qualified name is or - begins with that prefix, using codepoint-by-codepoint - (case-sensitive) matching. - The prefix of a Java or.NET type (e.g., - `java.math.` or `System.Globalization`). - This object. - The parameter is null. - The parameter is empty. - - - Adds the fully qualified name of a Java or.NET type for - use in type matching. - The fully qualified name of a Java or.NET class - (e.g., java.math.BigInteger or - System.Globalization.CultureInfo ). - This object. - The parameter is null. - The parameter is empty. - - - Contains utility methods that may have use outside of the - CBORObject class. - - - Internal API. - The parameter is an - internal parameter. - A CBORObject object. - - - Interface implemented by classes that convert objects of - arbitrary types to CBOR objects. - Type to convert to a CBOR object. - - - Converts an object to a CBOR object. - An object to convert to a CBOR object. - A CBOR object. - - - This is an internal API. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - This is an internal API. - The parameter is an - arbitrary object. - The return value is an internal value. - - - Classes that implement this interface can support - conversions from CBOR objects to a custom type and back. - Type of objects to convert to and from CBOR - objects. - - - Converts a CBOR object to a custom type. - A CBOR object to convert to the custom - type. - An object of the custom type after conversion. - - - An interface for reading Unicode characters from a data - source. - - - Reads a Unicode character from a data source. - Either a Unicode code point (from 0-0xd7ff or from 0xe000 - to 0x10ffff), or the value -1 indicating the end of the - source. - - - Reads a sequence of Unicode code points from a data - source. - Output buffer. - Index in the output buffer to start writing - to. - Maximum number of code points to - write. - Either a Unicode code point (from 0-0xd7ff or from 0xe000 - to 0x10ffff), or the value -1 indicating the end of the - source. - Either "index" or - "length" is less than 0 or greater than - "chars"'s length, or "chars"'s length - minus "index" is less than - "length". - The parameter is null. - - - Includes options to control how CBOR objects are converted - to and from JavaScript Object Notation (JSON). - - - Specifies how JSON numbers are converted to CBOR objects - when decoding JSON (such as via FromJSONString or - ReadJSON ). None of these conversion modes affects how CBOR - objects are later encoded (such as via EncodeToBytes - ). - - - JSON numbers are decoded to CBOR using the full precision - given in the JSON text. The number will be converted to a CBOR - object as follows: If the number's exponent is 0 (after shifting - the decimal point to the end of the number without changing its - value), use the rules given in the - CBORObject.FromObject(EInteger) method; otherwise, use the - rules given in the CBORObject.FromObject(EDecimal) method. - An exception in version 4.x involves negative zeros; if the - negative zero's exponent is 0, it's written as a CBOR - floating-point number; otherwise the negative zero is written as an - EDecimal. - - - JSON numbers are decoded to CBOR as their closest-rounded - approximation as 64-bit binary floating-point numbers (using the - round-to-nearest/ties-to-even rounding mode). (In some cases, - numbers extremely close to zero may underflow to positive or - negative zero, and numbers of extremely large absolute value may - overflow to infinity.). It's important to note that this mode - affects only how JSON numbers are - decoded to a CBOR object; it doesn't affect how - EncodeToBytes and other methods encode CBOR objects. - Notably, by default, EncodeToBytes encodes CBOR - floating-point values to the CBOR format in their 16-bit - ("half-float"), 32-bit ("single-precision"), or 64-bit - ("double-precision") encoding form depending on the - value. - - - A JSON number is decoded to CBOR objects either as a CBOR - integer (major type 0 or 1) if the JSON number represents an - integer at least -(2^53)+1 and less than 2^53, or as their - closest-rounded approximation as 64-bit binary floating-point - numbers (using the round-to-nearest/ties-to-even rounding mode) - otherwise. For example, the JSON number - 0.99999999999999999999999999999999999 is not an integer, so it's - converted to its closest 64-bit binary floating-point - approximation, namely 1.0. (In some cases, numbers extremely close - to zero may underflow to positive or negative zero, and numbers of - extremely large absolute value may overflow to infinity.). It's - important to note that this mode affects only how JSON numbers are - decoded to a CBOR object; it doesn't affect how - EncodeToBytes and other methods encode CBOR objects. - Notably, by default, EncodeToBytes encodes CBOR - floating-point values to the CBOR format in their 16-bit - ("half-float"), 32-bit ("single-precision"), or 64-bit - ("double-precision") encoding form depending on the - value. - - - A JSON number is decoded to CBOR objects either as a CBOR - integer (major type 0 or 1) if the number's closest-rounded - approximation as a 64-bit binary floating-point number (using the - round-to-nearest/ties-to-even rounding mode) represents an integer - at least -(2^53)+1 and less than 2^53, or as that approximation - otherwise. For example, the JSON number - 0.99999999999999999999999999999999999 is the integer 1 when rounded - to its closest 64-bit binary floating-point approximation (1.0), so - it's converted to the CBOR integer 1 (major type 0). (In some - cases, numbers extremely close to zero may underflow to zero, and - numbers of extremely large absolute value may overflow to - infinity.). It's important to note that this mode affects only how - JSON numbers are - decoded to a CBOR object; it doesn't affect how - EncodeToBytes and other methods encode CBOR objects. - Notably, by default, EncodeToBytes encodes CBOR - floating-point values to the CBOR format in their 16-bit - ("half-float"), 32-bit ("single-precision"), or 64-bit - ("double-precision") encoding form depending on the - value. - - - JSON numbers are decoded to CBOR as their closest-rounded - approximation to an IEEE 854 decimal128 value, using the - round-to-nearest/ties-to-even rounding mode and the rules for the - EDecimal form of that approximation as given in the - CBORObject.FromObject(EDecimal) method. (In some cases, - numbers extremely close to zero may underflow to zero, and numbers - of extremely large absolute value may overflow to - infinity.). - - - Initializes a new instance of the - class with default - options. - - - Initializes a new instance of the - class with the given value - for the Base64Padding option. - Whether padding is included when - writing data in base64url or traditional base64 format to - JSON. - - - Initializes a new instance of the - class with the given values - for the options. - Whether padding is included when - writing data in base64url or traditional base64 format to - JSON. - Whether surrogate code points not - part of a surrogate pair (which consists of two consecutive - char s forming one Unicode code point) are each replaced - with a replacement character (U+FFFD). The default is false; an - exception is thrown when such code points are encountered. - - - Initializes a new instance of the - class. - A string setting forth the options to - use. This is a semicolon-separated list of options, each of which - has a key and a value separated by an equal sign ("="). Whitespace - and line separators are not allowed to appear between the - semicolons or between the equal signs, nor may the string begin or - end with whitespace. The string can be empty, but cannot be null. - The following is an example of this parameter: - base64padding=false;replacesurrogates=true. The key can be - any one of the following where the letters can be any combination - of basic upper-case and/or basic lower-case letters: - base64padding, replacesurrogates, - allowduplicatekeys, preservenegativezero, - numberconversion, writebasic, keepkeyorder. - Other keys are ignored in this version of the CBOR library. (Keys - are compared using a basic case-insensitive comparison, in which - two strings are equal if they match after converting the basic - upper-case letters A to Z (U+0041 to U+005A) in both strings to - basic lower-case letters.) If two or more key/value pairs have - equal keys (in a basic case-insensitive comparison), the value - given for the last such key is used. The first four keys just given - can have a value of 1, true, yes, or - on (where the letters can be any combination of basic - upper-case and/or basic lower-case letters), which means true, and - any other value meaning false. The last key, - numberconversion, can have a value of any name given in the - JSONOptions.ConversionMode enumeration (where the letters - can be any combination of basic upper-case and/or basic lower-case - letters), and any other value is unrecognized. (If the - numberconversion key is not given, its value is treated as - full. If that key is given, but has an unrecognized value, - an exception is thrown.) For example, base64padding=Yes and - base64padding=1 both set the Base64Padding property - to true, and numberconversion=double sets the - NumberConversion property to ConversionMode.Double - . - The parameter is null. In the future, this class may allow - other keys to store other kinds of values, not just true or - false. - An unrecognized value for - numberconversion was given. - - - Gets the values of this options object's properties in - text form. - A text string containing the values of this options - object's properties. The format of the string is the same as the - one described in the String constructor for this class. - - - The default options for converting CBOR objects to - JSON. - - - Gets a value indicating whether the Base64Padding property - is true. This property has no effect; in previous versions, this - property meant that padding was written out when writing base64url - or traditional base64 to JSON. - A value indicating whether the Base64Padding property is - true. - - - Gets a value indicating whether the JSON decoder should - preserve the distinction between positive zero and negative zero - when the decoder decodes JSON to a floating-point number format - that makes this distinction. For a value of false, if the - result of parsing a JSON string would be a floating-point negative - zero, that result is a positive zero instead. (Note that this - property has no effect for conversion kind - IntOrFloatFromDouble, where floating-point zeros are not - possible.). - A value indicating whether to preserve the distinction - between positive zero and negative zero when decoding JSON. The - default is true. - - - Gets a value indicating how JSON numbers are decoded to - CBOR objects. None of the conversion modes affects how CBOR objects - are later encoded (such as via EncodeToBytes ). - A value indicating how JSON numbers are decoded to CBOR. The - default is ConversionMode.Full. - - - Gets a value indicating whether JSON is written using only - code points from the Basic Latin block (U+0000 to U+007F), also - known as ASCII. - A value indicating whether JSON is written using only code - points from the Basic Latin block (U+0000 to U+007F), also known as - ASCII. Default is false. - - - Gets a value indicating whether to preserve the order in - which a map's keys appear when decoding JSON, by using maps created - as though by CBORObject.NewOrderedMap. If false, key order is not - guaranteed to be preserved when decoding JSON. - A value indicating whether to preserve the order in which a - CBOR map's keys appear when decoding JSON. The default is - false. - - - Gets a value indicating whether to allow duplicate keys - when reading JSON. Used only when decoding JSON. If this property - is true and a JSON object has two or more values with the - same key, the last value of that key set forth in the JSON object - is taken. - A value indicating whether to allow duplicate keys when - reading JSON. The default is false. - - - Gets a value indicating whether surrogate code points not - part of a surrogate pair (which consists of two consecutive - char s forming one Unicode code point) are each replaced - with a replacement character (U+FFFD). If false, an exception is - thrown when such code points are encountered. - True, if surrogate code points not part of a surrogate pair - are each replaced with a replacement character, or false if an - exception is thrown when such code points are encountered. The - default is false. - - - Gets an index into the specified object, if the object is - an array and is not greater than the array's length. - The index contained in this instance, or -1 if the object - isn't a JSON array or is greater than the array's length. - - - Gets all children of the specified JSON object that - contain the specified key; the method will remove matching keys. As - an example, consider this object: -
[{"key":"value1","foo":"foovalue"},
-            {"key":"value2","bar":"barvalue"}, {"baz":"bazvalue"}]
If - getPointersToKey is called on this object with a keyToFind called - "key", we get the following Map as the return value: -
{ "/0" => "value1", // "/0" points to {"foo":"foovalue"} "/1"
-            => "value2" /* "/1" points to {"bar":"barvalue"} */ }
and the - JSON object will change to the following: -
[{"foo":"foovalue"}, {"bar":"barvalue"},
-            {"baz","bazvalue"}]
.
- The object to search. - The key to search for. - A map: - - The keys in the map are JSON Pointers to the objects within - root that contained a key named - keyToFind. To get the actual JSON object, call - JSONPointer.GetObject, passing - root and the pointer as arguments. - The values in the map are the values of each of those keys - named - keyToFind. The JSON Pointers are relative to - the root object. - The parameter is null. -
- - Gets all children of the specified JSON object that - contain the specified key; the method will not remove matching - keys. As an example, consider this object: -
[{"key":"value1","foo":"foovalue"},
-            {"key":"value2","bar":"barvalue"}, {"baz":"bazvalue"}]
If - getPointersToKey is called on this object with a keyToFind called - "key", we get the following Map as the return value: -
{ "/0" => "value1", // "/0" points to
-            {"key":"value1","foo":"foovalue"} "/1" => "value2" // "/1" points
-            to {"key":"value2","bar":"barvalue"} }
and the JSON object - will remain unchanged. - - The keys in the map are JSON Pointers to the objects within - root that contained a key named - keyToFind. To get the actual JSON object, call - JSONPointer.GetObject, passing - root and the pointer as arguments. - The values in the map are the values of each of those keys - named - keyToFind. The JSON Pointers are relative to - the root object.
- Object to search. - The key to search for. - A map:. - The parameter is null. -
- - Options for controlling how certain DotNET or Java - objects, such as so-called "plain old data" objects (better known - as POCOs in DotNET or POJOs in Java), are converted to CBOR - objects. - - - Initializes a new instance of the - class with all the default - options. - - - Initializes a new instance of the - class. - The parameter is not used. - The value of the "UseCamelCase" - property. - - - Initializes a new instance of the - class. - A string setting forth the options to - use. This is a semicolon-separated list of options, each of which - has a key and a value separated by an equal sign ("="). Whitespace - and line separators are not allowed to appear between the - semicolons or between the equal signs, nor may the string begin or - end with whitespace. The string can be empty, but cannot be null. - The following is an example of this parameter: - usecamelcase=true. The key can be any one of the following - where the letters can be any combination of basic upper-case and/or - basic lower-case letters: usecamelcase. Other keys are - ignored in this version of the CBOR library. (Keys are compared - using a basic case-insensitive comparison, in which two strings are - equal if they match after converting the basic upper-case letters A - to Z (U+0041 to U+005A) in both strings to basic lower-case - letters.) If two or more key/value pairs have equal keys (in a - basic case-insensitive comparison), the value given for the last - such key is used. The key just given can have a value of 1, - true, yes, or on (where the letters can be - any combination of basic upper-case and/or basic lower-case - letters), which means true, and any other value meaning false. For - example, usecamelcase=Yes and usecamelcase=1 both set - the UseCamelCase property to true. In the future, this class - may allow other keys to store other kinds of values, not just true - or false. - The parameter is null. - - - Gets the values of this options object's properties in - text form. - A text string containing the values of this options - object's properties. The format of the string is the same as the - one described in the String constructor for this class. - - - The default settings for "plain old data" - options. - - - - Gets a value indicating whether property, field, and method - names are converted to camel case before they are used as keys. - This option changes the behavior of key name serialization as - follows. If "useCamelCase" is false : - - In the .NET version, all key names are capitalized, meaning - the first letter in the name is converted to a basic upper-case - letter if it's a basic lower-case letter ("a" to "z"). (For - example, "Name" and "IsName" both remain unchanged.) - In the Java version, all field names are capitalized, and for - each eligible method name, the word "get" or "set" is removed from - the name if the name starts with that word, then the name is - capitalized. (For example, "getName" and "setName" both become - "Name", and "isName" becomes "IsName".) - If "useCamelCase" is true : - - In the .NET version, for each eligible property or field - name, the word "Is" is removed from the name if the name starts - with that word, then the name is converted to camel case, meaning - the first letter in the name is converted to a basic lower-case - letter if it's a basic upper-case letter ("A" to "Z"). (For - example, "Name" and "IsName" both become "name".) - In the Java version: For each eligible method name, the word - "get", "set", or "is" is removed from the name if the name starts - with that word, then the name is converted to camel case. (For - example, "getName", "setName", and "isName" all become "name".) For - each eligible field name, the word "is" is removed from the name if - the name starts with that word, then the name is converted to camel - case. (For example, "name" and "isName" both become - "name".) - In the description above, a name "starts with" a word if that - word begins the name and is followed by a character other than a - basic digit or basic lower-case letter, that is, other than "a" to - "z" or "0" to "9". - true If the names are converted to camel case; - otherwise, false. This property is true by - default. - - - Implements CBOR string references, described at - http://cbor.schmorp.de/stringref. - - - Contains methods useful for reading and writing text - strings. It is designed to have no dependencies other than the - basic runtime class library. - Many of these methods work with text encoded in UTF-8, an - encoding form of the Unicode Standard which uses one byte to encode - the most basic characters and two to four bytes to encode other - characters. For example, the GetUtf8 method converts a text - string to an array of bytes in UTF-8. - In C# and Java, text strings are represented as sequences of - 16-bit values called char s. These sequences are well-formed - under UTF-16, a 16-bit encoding form of Unicode, except if they - contain unpaired surrogate code points. (A surrogate code point is - used to encode supplementary characters, those with code points - U+10000 or higher, in UTF-16. A surrogate pair is a high surrogate, - U+D800 to U+DBFF, followed by a low surrogate, U+DC00 to U+DFFF. An - unpaired surrogate code point is a surrogate not appearing in a - surrogate pair.) Many of the methods in this class allow setting - the behavior to follow when unpaired surrogate code points are - found in text strings, such as throwing an error or treating the - unpaired surrogate as a replacement character - (U+FFFD). - - - Generates a text string from a UTF-8 byte array. - A byte array containing text encoded in - UTF-8. - If true, replaces invalid encoding with the - replacement character (U+FFFD). If false, stops processing when - invalid UTF-8 is seen. - A string represented by the UTF-8 byte array. - The parameter is null. - The string is not valid UTF-8 - and is false. - - - Finds the number of Unicode code points in the given text - string. Unpaired surrogate code points increase this number by 1. - This is not necessarily the length of the string in "char" - s. - The parameter is a text - string. - The number of Unicode code points in the given - string. - The parameter is null. - - - Generates a text string from a portion of a UTF-8 byte - array. - A byte array containing text encoded in - UTF-8. - Offset into the byte array to start - reading. - Length, in bytes, of the UTF-8 text - string. - If true, replaces invalid encoding with the - replacement character (U+FFFD). If false, stops processing when - invalid UTF-8 is seen. - A string represented by the UTF-8 byte array. - The parameter is null. - The portion of the byte array - is not valid UTF-8 and is - false. - The parameter is less than 0, is - less than 0, or offset plus bytesCount is greater than the length - of "data" . - - - - Encodes a string in UTF-8 as a byte array. This method does - not insert a byte-order mark (U+FEFF) at the beginning of the - encoded byte array. - REMARK: It is not recommended to use - Encoding.UTF8.GetBytes in.NET, or the getBytes() - method in Java to do this. For instance, getBytes() encodes - text strings in a default (so not fixed) character encoding, which - can be undesirable. - The parameter is a text - string. - If true, replaces unpaired surrogate code - points with the replacement character (U+FFFD). If false, stops - processing when an unpaired surrogate code point is seen. - The string encoded in UTF-8. - The parameter is null. - The string contains an unpaired - surrogate code point and is false, or an - internal error occurred. - - - - Encodes a string in UTF-8 as a byte array. This method does - not insert a byte-order mark (U+FEFF) at the beginning of the - encoded byte array. - REMARK: It is not recommended to use - Encoding.UTF8.GetBytes in.NET, or the getBytes() - method in Java to do this. For instance, getBytes() encodes - text strings in a default (so not fixed) character encoding, which - can be undesirable. - The parameter is a text - string. - If true, replaces unpaired surrogate code - points with the replacement character (U+FFFD). If false, stops - processing when an unpaired surrogate code point is seen. - If true, replaces carriage return - (CR) not followed by line feed (LF) and LF not preceded by CR with - CR-LF pairs. - The string encoded in UTF-8. - The parameter is null. - The string contains an unpaired - surrogate code point and is false, or an - internal error occurred. - - - Calculates the number of bytes needed to encode a string - in UTF-8. - The parameter is a text - string. - If true, treats unpaired surrogate code - points as having 3 UTF-8 bytes (the UTF-8 length of the replacement - character U+FFFD). - The number of bytes needed to encode the given string in - UTF-8, or -1 if the string contains an unpaired surrogate code - point and is false. - The parameter is null. - - - Gets the Unicode code point just before the given index of - the string. - The parameter is a text - string. - Index of the current position into the - string. - The Unicode code point at the previous position. Returns - -1 if is 0 or less, or is greater than or - equal to the string's length. Returns the replacement character - (U+FFFD) if the code point at the previous position is an unpaired - surrogate code point. If the return value is 65536 (0x10000) or - greater, the code point takes up two UTF-16 code units. - The parameter is null. - - - Gets the Unicode code point just before the given index of - the string. - The parameter is a text - string. - Index of the current position into the - string. - Specifies what kind of value to - return if the previous code point is an unpaired surrogate code - point: if 0, return the replacement character (U+FFFD); if 1, - return the value of the surrogate code point; if neither 0 nor 1, - return -1. - The Unicode code point at the previous position. Returns - -1 if is 0 or less, or is greater than or - equal to the string's length. Returns a value as specified under - if the code point at the - previous position is an unpaired surrogate code point. If the - return value is 65536 (0x10000) or greater, the code point takes up - two UTF-16 code units. - The parameter is null. - - - Gets the Unicode code point at the given index of the - string. - The parameter is a text - string. - Index of the current position into the - string. - The Unicode code point at the given position. Returns -1 - if is 0 or less, or is greater than or - equal to the string's length. Returns the replacement character - (U+FFFD) if the code point at that position is an unpaired - surrogate code point. If the return value is 65536 (0x10000) or - greater, the code point takes up two UTF-16 code units. - The parameter is null. - - - Gets the Unicode code point at the given index of the - string. - The parameter is a text - string. - Index of the current position into the - string. - Specifies what kind of value to - return if the code point at the given index is an unpaired - surrogate code point: if 0, return the replacement character (U + - FFFD); if 1, return the value of the surrogate code point; if - neither 0 nor 1, return -1. - The Unicode code point at the given position. Returns -1 - if is 0 or less, or is greater than or - equal to the string's length. Returns a value as specified under - if the code point at that - position is an unpaired surrogate code point. If the return value - is 65536 (0x10000) or greater, the code point takes up two UTF-16 - code units. - The parameter is null. - - The following example shows how to iterate a text string code - point by code point, terminating the loop when an unpaired - surrogate is found. - for (var i = 0;i<str.Length; ++i) { int codePoint = - DataUtilities.CodePointAt(str, i, 2); if (codePoint < 0) { break; /* - Unpaired surrogate */ } Console.WriteLine("codePoint:"+codePoint); if - (codePoint >= 0x10000) { i++; /* Supplementary code point */ } } - . - - - - Returns a string with the basic upper-case letters A to Z - (U+0041 to U+005A) converted to the corresponding basic lower-case - letters. Other characters remain unchanged. - The parameter is a text - string. - The converted string, or null if is - null. - - - Returns a string with the basic lower-case letters A to Z - (U+0061 to U+007A) converted to the corresponding basic upper-case - letters. Other characters remain unchanged. - The parameter is a text - string. - The converted string, or null if is - null. - - - Compares two strings in Unicode code point order. Unpaired - surrogate code points are treated as individual code - points. - The first string. Can be null. - The second string. Can be null. - A value indicating which string is " less" or " greater" . - 0: Both strings are equal or null. Less than 0: a is null and b - isn't; or the first code point that's different is less in A than - in B; or b starts with a and is longer than a. Greater than 0: b is - null and a isn't; or the first code point that's different is - greater in A than in B; or a starts with b and is longer than - b. - - - Writes a portion of a string in UTF-8 encoding to a data - stream. - A string to write. - The Index starting at 0 where the string - portion to write begins. - The length of the string portion to - write. - A writable data stream. - If true, replaces unpaired surrogate code - points with the replacement character (U+FFFD). If false, stops - processing when an unpaired surrogate code point is seen. - 0 if the entire string portion was written; or -1 if the - string portion contains an unpaired surrogate code point and - is false. - The parameter is null or is - null. - An I/O error - occurred. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - Writes a portion of a string in UTF-8 encoding to a data - stream. - A string to write. - The Index starting at 0 where the string - portion to write begins. - The length of the string portion to - write. - A writable data stream. - If true, replaces unpaired surrogate code - points with the replacement character (U+FFFD). If false, stops - processing when an unpaired surrogate code point is seen. - If true, replaces carriage return - (CR) not followed by line feed (LF) and LF not preceded by CR with - CR-LF pairs. - 0 if the entire string portion was written; or -1 if the - string portion contains an unpaired surrogate code point and - is false. - The parameter is null or is - null. - The parameter is less than 0, is less - than 0, or plus - is greater than the string's length. - An I/O error - occurred. - - - Writes a string in UTF-8 encoding to a data - stream. - A string to write. - A writable data stream. - If true, replaces unpaired surrogate code - points with the replacement character (U+FFFD). If false, stops - processing when an unpaired surrogate code point is seen. - 0 if the entire string was written; or -1 if the string - contains an unpaired surrogate code point and is false. - The parameter is null or is - null. - An I/O error - occurred. - - - Reads a string in UTF-8 encoding from a byte - array. - A byte array containing a UTF-8 text - string. - Offset into the byte array to start - reading. - Length, in bytes, of the UTF-8 text - string. - A string builder object where the resulting - string will be stored. - If true, replaces invalid encoding with the - replacement character (U+FFFD). If false, stops processing when - invalid UTF-8 is seen. - 0 if the entire string was read without errors, or -1 if - the string is not valid UTF-8 and is - false. - The parameter is null or is - null. - The parameter is less than 0, is - less than 0, or offset plus bytesCount is greater than the length - of . - - - Reads a string in UTF-8 encoding from a data stream in - full and returns that string. Replaces invalid encoding with the - replacement character (U+FFFD). - A readable data stream. - The string read. - An I/O error - occurred. - The parameter is null. - - - Reads a string in UTF-8 encoding from a data stream and - returns that string. - A readable data stream. - The length, in bytes, of the string. If - this is less than 0, this function will read until the end of the - stream. - If true, replaces invalid encoding with the - replacement character (U+FFFD). If false, throws an error if an - unpaired surrogate code point is seen. - The string read. - An I/O error occurred; or, - the string is not valid UTF-8 and is - false. - The parameter is null. - - - Reads a string in UTF-8 encoding from a data - stream. - A readable data stream. - The length, in bytes, of the string. If - this is less than 0, this function will read until the end of the - stream. - A string builder object where the resulting - string will be stored. - If true, replaces invalid encoding with the - replacement character (U+FFFD). If false, stops processing when an - unpaired surrogate code point is seen. - 0 if the entire string was read without errors, -1 if the - string is not valid UTF-8 and is false, - or -2 if the end of the stream was reached before the last - character was read completely (which is only the case if is 0 or greater). - An I/O error - occurred. - The parameter is null or is - null. - -
-
diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.dll b/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.dll deleted file mode 100644 index f38aa243..00000000 Binary files a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.dll and /dev/null differ diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.dll.meta b/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.dll.meta deleted file mode 100644 index 21cb426e..00000000 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 6a8f5e72a2428e546820610cf82c511f -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.xml b/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.xml deleted file mode 100644 index 8ece5a1a..00000000 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.xml +++ /dev/null @@ -1,13500 +0,0 @@ - - - - Numbers - - - - Contains parameters for controlling the precision, - rounding, and exponent range of arbitrary-precision numbers. (The - "E" stands for "extended", and has this prefix to group it with the - other classes common to this library, particularly EDecimal, - EFloat, and ERational.). - Thread safety: With one exception, instances of this - class are immutable and are safe to use among multiple threads. The - one exception involves the Flags property. If the context's - HasFlags property (a read-only property) is true, - the Flags property is mutable, thus making the context - mutable. This class doesn't synchronize access to such mutable - contexts, so applications should provide their own synchronization - if a context with the HasFlags property set to true - will be shared among multiple threads and at least one of those - threads needs to write the Flags property (which can happen, - for example, by passing the context to most methods of - EDecimal such as Add ). - - - Signals that the exponent was adjusted to fit the exponent - range. - - - Signals a division of a nonzero number by zero. - - - Signals that the result was rounded to a different - mathematical value, but as close as possible to the - original. - - - Signals an invalid operation. - - - Signals that an operand was rounded to a different - mathematical value before an operation. - - - Signals that the result is non-zero and the exponent is - higher than the highest exponent allowed. - - - Signals that the result was rounded to fit the precision; - either the value or the exponent may have changed from the - original. - - - Signals that the result's exponent, before rounding, is - lower than the lowest exponent allowed. - - - Signals that the result's exponent, before rounding, is - lower than the lowest exponent allowed, and the result was rounded - to a different mathematical value, but as close as possible to the - original. - - - A basic arithmetic context, 9 digits precision, rounding - mode half-up, unlimited exponent range. The default rounding mode - is HalfUp. - - - An arithmetic context for Java's BigDecimal format. The - default rounding mode is HalfUp. - - - An arithmetic context for the IEEE-754-2008 binary128 - format, 113 bits precision. The default rounding mode is - HalfEven. - - - An arithmetic context for the IEEE-754-2008 binary16 - format, 11 bits precision. The default rounding mode is - HalfEven. - - - An arithmetic context for the IEEE-754-2008 binary32 - format, 24 bits precision. The default rounding mode is - HalfEven. - - - An arithmetic context for the IEEE-754-2008 binary64 - format, 53 bits precision. The default rounding mode is - HalfEven. - - - An arithmetic context for the.NET Framework decimal format - (see - "Forms of numbers" ), 96 - bits precision, and a valid exponent range of -28 to 0. The default - rounding mode is HalfEven. (The "Cli" stands for "Common - Language Infrastructure", which defined this format as the .NET - Framework decimal format in version 1, but leaves it unspecified in - later versions.). - - - An arithmetic context for the IEEE-754-2008 decimal128 - format. The default rounding mode is HalfEven. - - - An arithmetic context for the IEEE-754-2008 decimal32 - format. The default rounding mode is HalfEven. - - - An arithmetic context for the IEEE-754-2008 decimal64 - format. The default rounding mode is HalfEven. - - - No specific (theoretical) limit on precision. Rounding - mode HalfUp. - - - No specific (theoretical) limit on precision. Rounding - mode HalfEven. - - - Initializes a new instance of the - class. - The value of the Precision - property. - The value of the Rounding property. - The value of the EMin - property. - The value of the EMax - property. - The value of the - ClampNormalExponents property. - - - Initializes a new instance of the - class,. - The value of the Precision - property. - The value of the Rounding property. - The value of the EMin property. - The value of the EMax property. - The value of the - ClampNormalExponents property. - - - Gets a value indicating whether the EMax and EMin - properties refer to the number's Exponent property adjusted to the - number's precision, or just the number's Exponent property. The - default value is true, meaning that EMax and EMin refer to the - adjusted exponent. Setting this value to false (using - WithAdjustExponent) is useful for modeling floating point - representations with an integer significand and an integer - exponent, such as Java's BigDecimal. - true if the EMax and EMin properties refer to the - number's Exponent property adjusted to the number's precision, or - false if they refer to just the number's Exponent property. - - - Gets a value indicating whether a converted number's - Exponent property will not be higher than EMax + 1 - Precision. If - a number's exponent is higher than that value, but not high enough - to cause overflow, the exponent is clamped to that value and enough - zeros are added to the number's significand to account for the - adjustment. If HasExponentRange is false, this value is always - false. - If true, a converted number's Exponent property will not be - higher than EMax + 1 - Precision. - - - Gets the highest exponent possible when a converted number - is expressed in scientific notation with one nonzero digit before - the radix point. For example, with a precision of 3 and an EMax of - 100, the maximum value possible is 9.99E + 100. (This is not the - same as the highest possible Exponent property.) If - HasExponentRange is false, this value will be 0. - The highest exponent possible when a converted number is - expressed in scientific notation with one nonzero digit before the - radix point. For example, with a precision of 3 and an EMax of 100, - the maximum value possible is 9.99E + 100. (This is not the same as - the highest possible Exponent property.) If HasExponentRange is - false, this value will be 0. - - - Gets the lowest exponent possible when a converted number - is expressed in scientific notation with one nonzero digit before - the radix point. For example, with a precision of 3 and an EMin of - -100, the next value that comes after 0 is 0.001E-100. (If - AdjustExponent is false, this property specifies the lowest - possible Exponent property instead.) If HasExponentRange is false, - this value will be 0. - The lowest exponent possible when a converted number is - expressed in scientific notation with one nonzero digit before the - radix point. For example, with a precision of 3 and an EMin of - -100, the next value that comes after 0 is 0.001E-100. (If - AdjustExponent is false, this property specifies the lowest - possible Exponent property instead.) If HasExponentRange is false, - this value will be 0. - - - Gets or sets the flags that are set from converting - numbers according to this arithmetic context. If HasFlags is - false, this value will be 0. This value is a combination of bit - fields. To retrieve a particular flag, use the AND operation on the - return value of this method. For example: (this.Flags - &EContext.FlagInexact) != 0 returns true if the - Inexact flag is set. - The flags that are set from converting numbers according to - this arithmetic context. If HasFlags is false, this value - will be 0. This value is a combination of bit fields. To retrieve a - particular flag, use the AND operation on the return value of this - method. For example: (this.Flags &EContext.FlagInexact) - !=0 returns true if the Inexact flag is set. - - - Gets a value indicating whether this context defines a - minimum and maximum exponent. If false, converted exponents can - have any exponent and operations can't cause overflow or - underflow. - true if this context defines a minimum and maximum - exponent; otherwise, false.. If false, converted exponents - can have any exponent and operations can't cause overflow or - underflow. true if this context defines a minimum and - maximum exponent; otherwise, false. - - - Gets a value indicating whether this context has a mutable - Flags field. - true if this context has a mutable Flags field; - otherwise, false. - - - Gets a value indicating whether this context defines a - maximum precision. This is the same as whether this context's - Precision property is zero. - true if this context defines a maximum precision; - otherwise, false. - - - Gets a value indicating whether this context's Precision - property is in bits, rather than digits. The default is - false. - true if this context's Precision property is in bits, - rather than digits; otherwise, false.. The default is - false. true if this context's Precision property is in bits, - rather than digits; otherwise, false. The default is - false. - - - Gets a value indicating whether to use a "simplified" - arithmetic. In the simplified arithmetic, infinity, not-a-number, - and subnormal numbers are not allowed, and negative zero is treated - the same as positive zero. For further details, see - http://speleotrove.com/decimal/dax3274.html - . - true if to use a "simplified" arithmetic; otherwise, - false In the simplified arithmetic, infinity, not-a-number, - and subnormal numbers are not allowed, and negative zero is treated - the same as positive zero. For further details, see - http://speleotrove.com/decimal/dax3274.html - . true if a "simplified" arithmetic will be used; otherwise, - false. - - - Gets the maximum length of a converted number in digits, - ignoring the radix point and exponent. For example, if precision is - 3, a converted number's significand can range from 0 to 999 (up to - three digits long). If 0, converted numbers can have any precision. - Not-a-number (NaN) values can carry an optional number, its - payload, that serves as its "diagnostic information", In general, - if an operation requires copying an NaN's payload, only up to as - many digits of that payload as the precision given in this context, - namely the least significant digits, are copied. - The maximum length of a converted number in digits, ignoring - the radix point and exponent. For example, if precision is 3, a - converted number's significand can range from 0 to 999 (up to three - digits long). If 0, converted numbers can have any - precision. - - - Gets the desired rounding mode when converting numbers - that can't be represented in the given precision and exponent - range. - The desired rounding mode when converting numbers that can't - be represented in the given precision and exponent range. - - - Gets the traps that are set for each flag in the context. - Whenever a flag is signaled, even if HasFlags is false, and - the flag's trap is enabled, the operation will throw a - TrapException. - For example, if Traps equals FlagInexact and - FlagSubnormal, a TrapException will be thrown if an operation's - return value is not the same as the exact result (FlagInexact) or - if the return value's exponent is lower than the lowest allowed - (FlagSubnormal). - The traps that are set for each flag in the context. - Whenever a flag is signaled, even if HasFlags is false, and - the flag's trap is enabled, the operation will throw a - TrapException. - For example, if Traps equals FlagInexact and - FlagSubnormal, a TrapException will be thrown if an operation's - return value is not the same as the exact result (FlagInexact) or - if the return value's exponent is lower than the lowest allowed - (FlagSubnormal).. - - - Creates a new arithmetic context using the given maximum - number of digits, an unlimited exponent range, and the HalfUp - rounding mode. - Maximum number of digits - (precision). - A context object for arbitrary-precision arithmetic - settings. - - - Creates a new EContext object initialized with an - unlimited exponent range, and the given rounding mode and maximum - precision. - Maximum number of digits - (precision). - The parameter is - an ERounding object. - A context object for arbitrary-precision arithmetic - settings. - - - Creates a new EContext object initialized with an - unlimited precision, an unlimited exponent range, and the given - rounding mode. - The rounding mode for the new precision - context. - A context object for arbitrary-precision arithmetic - settings. - - - Initializes a new EContext that is a copy of another - EContext. - A context object for arbitrary-precision arithmetic - settings. - - - Determines whether a number can have the given Exponent - property under this arithmetic context. - An arbitrary-precision integer indicating - the desired exponent. - true if a number can have the given Exponent - property under this arithmetic context; otherwise, false. - If this context allows unlimited precision, returns true for the - exponent EMax and any exponent less than EMax. - The parameter is null. - - - Returns this object in a text form intended to be read by - humans. The value returned by this method is not intended to be - parsed by computer programs, and the exact text of the value may - change at any time between versions of this library. - A string representation of this object. - - - Gets a value indicating whether this context has a mutable - Flags field, one or more trap enablers, or both. - true if this context has a mutable Flags field, one - or more trap enablers, or both; otherwise, false. - - - Copies this EContext and sets the copy's "AdjustExponent" - property to the given value. - The new value of the "AdjustExponent" - property for the copy. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this arithmetic context and sets the copy's - exponent range. - Desired minimum exponent (EMin). - Desired maximum exponent (EMax). - A context object for arbitrary-precision arithmetic - settings. - The parameter is null. - ExponentMin greater than - exponentMax". - - - Copies this EContext with HasFlags set to false, a - Traps value of 0, and a Flags value of 0. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext and gives it a particular precision - value. - Desired precision. 0 means unlimited - precision. - A context object for arbitrary-precision arithmetic - settings. - The parameter is null. - - - Copies this EContext with HasFlags set to true and - a Flags value of 0. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this arithmetic context and sets the copy's - "ClampNormalExponents" flag to the given value. - The desired value of the "ClampNormalExponents" - flag. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this arithmetic context and sets the copy's - exponent range. - Desired minimum exponent - (EMin). - Desired maximum exponent - (EMax). - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext with HasFlags set to false and - a Flags value of 0. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext and gives it a particular precision - value. - Desired precision. 0 means unlimited - precision. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext and sets the copy's - "IsPrecisionInBits" property to the given value. - The new value of the - "IsPrecisionInBits" property for the copy. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext with the specified rounding - mode. - Desired value of the Rounding - property. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext and sets the copy's "IsSimplified" - property to the given value. - Desired value of the IsSimplified - property. - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext with Traps set to the given value. - (Also sets HasFlags on the copy to True, but this may - change in version 2.0 of this library.). - Flags representing the traps to enable. See the - property "Traps". - A context object for arbitrary-precision arithmetic - settings. - - - Copies this EContext with an unlimited exponent - range. - A context object for arbitrary-precision arithmetic - settings. - - - Returns this context if it doesn't set traps, or a context - without traps and with blank flags if it does, so that the - resulting context does not cause trap exceptions to occur. This is - not a general-purpose method; it is intended to support custom - implementations of arithmetic operations. - This context if it doesn't set traps, or a context without - traps and with blank flags if it does. - - - Throws trap exceptions if the given context has flags set - that also have traps enabled for them in this context, and adds the - given context's flags to this context if HasFlags for this context - is true. This is not a general-purpose method; it is intended to - support custom implementations of arithmetic operations. - The result of the operation. - An arithmetic context, usually a - context returned by the GetNontrapping method. Can be null. - Data type for the result of the - operation. - The parameter if no trap - exceptions were thrown. - - - - Represents an arbitrary-precision decimal - floating-point number. (The "E" stands for "extended", - meaning that instances of this class can be values - other than numbers proper, such as infinity and - not-a-number.) - About decimal arithmetic - - Decimal (base-10) arithmetic, such as that provided by this - class, is appropriate for calculations involving such real-world - data as prices and other sums of money, tax rates, and - measurements. These calculations often involve multiplying or - dividing one decimal with another decimal, or performing other - operations on decimal numbers. Many of these calculations also rely - on rounding behavior in which the result after rounding is an - arbitrary-precision decimal number (for example, multiplying a - price by a premium rate, then rounding, should result in a decimal - amount of money). - On the other hand, most implementations of float - and - double - , including in C# and Java, store numbers in a binary - (base-2) floating-point format and use binary floating-point - arithmetic. Many decimal numbers can't be represented exactly in - binary floating-point format (regardless of its length). Applying - binary arithmetic to numbers intended to be decimals can sometimes - lead to unintuitive results, as is shown in the description for the - FromDouble() method of this class. - About EDecimal instances - - Each instance of this class consists of an integer - significand and an integer exponent, both arbitrary-precision. The - value of the number equals significand * 10^exponent. - The significand is the value of the digits that make up a - number, ignoring the decimal point and exponent. For example, in - the number 2356.78, the significand is 235678. The exponent is - where the "floating" decimal point of the number is located. A - positive exponent means "move it to the right", and a negative - exponent means "move it to the left." In the example 2, 356.78, the - exponent is -2, since it has 2 decimal places and the decimal point - is "moved to the left by 2." Therefore, in the arbitrary-precision - decimal representation, this number would be stored as 235678 * - 10^-2. - The significand and exponent format preserves trailing zeros - in the number's value. This may give rise to multiple ways to store - the same value. For example, 1.00 and 1 would be stored - differently, even though they have the same value. In the first - case, 100 * 10^-2 (100 with decimal point moved left by 2), and in - the second case, 1 * 10^0 (1 with decimal point moved 0). - This class also supports values for negative zero, - not-a-number (NaN) values, and infinity. Negative zero - is - generally used when a negative number is rounded to 0; it has the - same mathematical value as positive zero. Infinity - is - generally used when a non-zero number is divided by zero, or when a - very high or very low number can't be represented in a given - exponent range. Not-a-number - is generally used to signal - errors. - This class implements the General Decimal Arithmetic - Specification version 1.70 except part of chapter 6( - http://speleotrove.com/decimal/decarith.html - ). - Errors and Exceptions - - Passing a signaling NaN to any arithmetic operation shown - here will signal the flag FlagInvalid and return a quiet NaN, even - if another operand to that operation is a quiet NaN, unless the - operation's documentation expressly states that another result - happens when a signaling NaN is passed to that operation. - Passing a quiet NaN to any arithmetic operation shown here - will return a quiet NaN, unless the operation's documentation - expressly states that another result happens when a quiet NaN is - passed to that operation. Invalid operations will also return a - quiet NaN, as stated in the individual methods. - Unless noted otherwise, passing a null arbitrary-precision - decimal argument to any method here will throw an exception. - When an arithmetic operation signals the flag FlagInvalid, - FlagOverflow, or FlagDivideByZero, it will not throw an exception - too, unless the flag's trap is enabled in the arithmetic context - (see EContext's Traps property). - If an operation requires creating an intermediate value that - might be too big to fit in memory (or might require more than 2 - gigabytes of memory to store -- due to the current use of a 32-bit - integer internally as a length), the operation may signal an - invalid-operation flag and return not-a-number (NaN). In certain - rare cases, the CompareTo method may throw OutOfMemoryException - (called OutOfMemoryError in Java) in the same circumstances. - Serialization - - An arbitrary-precision decimal value can be serialized - (converted to a stable format) in one of the following ways: - By calling the toString() method, which will always - return distinct strings for distinct arbitrary-precision decimal - values. - By calling the UnsignedMantissa, Exponent, and - IsNegative properties, and calling the IsInfinity, IsQuietNaN, and - IsSignalingNaN methods. The return values combined will uniquely - identify a particular arbitrary-precision decimal value. - - Thread safety - - Instances of this class are immutable, so they are inherently - safe for use by multiple threads. Multiple instances of this object - with the same properties are interchangeable, so they should not be - compared using the "==" operator (which might only check if each - side of the operator is the same instance). - Comparison considerations - - This class's natural ordering (under the CompareTo method) is - not consistent with the Equals method. This means that two values - that compare as equal under the CompareTo method might not be equal - under the Equals method. The CompareTo method compares the - mathematical values of the two instances passed to it (and - considers two different NaN values as equal), while two instances - with the same mathematical value, but different exponents, will be - considered unequal under the Equals method. - Security note - - It is not recommended to implement security-sensitive - algorithms using the methods in this class, for several - reasons: - EDecimal - objects are immutable, so they can't be - modified, and the memory they occupy is not guaranteed to be - cleared in a timely fashion due to garbage collection. This is - relevant for applications that use many-digit-long numbers as - secret parameters. - The methods in this class - (especially those that involve arithmetic) are not guaranteed to be - "constant-time" (non-data-dependent) for all relevant inputs. - Certain attacks that involve encrypted communications have - exploited the timing and other aspects of such communications to - derive keying material or cleartext indirectly. - - Applications should instead use dedicated security libraries - to handle big numbers in security-sensitive algorithms. - Reproducibility note - - Some applications, such as simulations, care about results - that are reproducible, bit for bit, across computers and across - runs of the application. Bruce Dawson, in "Floating-Point - Determinism" ( https://randomascii.wordpress.com/ - 2013/07/16/floating-point-determinism/ - ), identified many - reproducibility issues with floating-point numbers, and here is how - they relate to the EDecimal and EFloat classes of this - library: - Runtime floating-point settings: All the settings that - change how EDecimal and EFloat behave are given as parameters to - the appropriate methods, especially via EContext objects, which - specify the precision, rounding, and exponent range of numbers, - among other things. The EDecimal and EFloat classes avoid the use - of "native" floating-point data types (except for methods that - convert to or from float - , double - , or - System.Decimal - ). Such "native" types are often subject to - runtime settings that change how floating-point math behaves with - them, and these settings are often not accessible to .NET or Java - code. - Non-associativity and intermediate precisions: - In general, EDecimal and EFloat use "unlimited" precision in their - calculations unless specified otherwise by an EContext object. - However, by limiting the precision of EDecimal, EFloat, and other - floating-point numbers in this way, operations such as addition and - multiplication on three or more numbers can be - non-associative - , meaning the result can change depending on - the order in which those numbers are added or multiplied. This - property means that if an algorithm does not ensure such numbers - are added or multiplied in the same order every time, its results - may not be reproducible across computers or across runs of the - application. This non-associativity problem can happen, for - example, if an application splits a calculation across several - threads and combines their results in the end. The problems with an - unspecified order of operations (in the same line of code) and - intermediate precisions (problems present in C and C++, for - example) don't exist with method calls to EDecimal and EFloat - methods, especially since they require limited-precision support to - be declared explicitly via EContext. - fmadd - instruction: EDecimal and EFloat include a MultiplyAndAdd method - with the same semantics as in the General Decimal Arithmetic - Specification, which requires delivering correctly rounded results - for this method. - Square root estimate: Not applicable - since EDecimal and EFloat don't include any estimates to square - root. - Transcendental functions: This includes - logarithms, exponentials, and the Pi method. For these functions, - results are not guaranteed to always be correctly rounded. When - using transcendentals, an application that cares about - reproducibility should choose one version of this library and stick - to it; this at least has the advantage that the implementation will - be the same across computers, unlike with "native" floating-point - types where the choice of implementation is often not within the - application's control. - Conversions: Conversions - between EDecimal or EFloat and text strings have the same - implementation across computers for the same version of this - library (see also the advice for transcendentals above). But as for - the ToDouble, ToSingle, FromDouble, and FromSingle methods, note - that some implementations of Java and.NET may or may not support - preserving the value of subnormal numbers (numbers other than zero - with the lowest possible exponent) or the payloads held in a - not-a-number (NaN) value of float or double; thus these methods - should not be considered reproducible across computers. - Compiler differences: Not applicable where these classes - don't use "native" floating-point types. - Uninitialized - data; per-processor code: Not applicable. - - Forms of numbers - - There are several other types of numbers that are mentioned - in this class and elsewhere in this documentation. For reference, - they are specified here. - Unsigned integer - : An integer that's always 0 or - greater, with the following maximum values: - 8-bit unsigned integer, or byte - : 255. - 16-bit unsigned integer: 65535. - 32-bit unsigned - integer: (2 32 - -1). - 64-bit unsigned - integer: (2 64 - -1). - - Signed integer - : An integer in two's-complement - form - , with the following ranges: - 8-bit signed integer: -128 to 127. - 16-bit - signed integer: -32768 to 32767. - 32-bit signed - integer: -2 31 - to (2 31 - - 1). - 64-bit signed integer: -2 63 - to (2 63 - - - 1). - - Two's complement form - : In two's-complement - form - , nonnegative numbers have the highest (most significant) - bit set to zero, and negative numbers have that bit (and all bits - beyond) set to one, and a negative number is stored in such form by - decreasing its absolute value by 1 and swapping the bits of the - resulting number. - 64-bit floating-point number - : A 64-bit binary - floating-point number, in the form significand - * 2 - exponent - - . The significand is 53 bits long - (Precision) and the exponent ranges from -1074 (EMin) to 971 - (EMax). The number is stored in the following format (commonly - called the IEEE 754 format): - |C|BBB...BBB|AAAAAA...AAAAAA| - A. Low 52 bits (Precision minus 1 bits): Lowest bits of - the significand. - B. Next 11 bits: Exponent area: - If all bits are ones, the final stored value is - infinity (positive or negative depending on the C bit) if all bits - in area A are zeros, or not-a-number (NaN) otherwise. - If all bits are zeros, the final stored value is a subnormal - number, the exponent is EMin, and the highest bit of the - significand is zero. - If any other number, the exponent - is this value reduced by 1, then raised by EMin, and the highest - bit of the significand is one. - - - C. - Highest bit: If one, this is a negative number. - - The elements described above are in the same order as the - order of each bit of each element, that is, either most significant - first or least significant first. - 32-bit binary floating-point number - : A 32-bit binary - number which is stored similarly to a 64-bit floating-point - number - , except that: - Precision is 24 bits. - EMin is -149. - EMax is 104. - A. The low 23 bits (Precision minus - 1 bits) are the lowest bits of the significand. - B. The - next 8 bits are the exponent area. - C. If the highest - bit is one, this is a negative number. - - .NET Framework decimal - : A 128-bit decimal - floating-point number, in the form significand - * 10 - - scale - - , where the scale ranges from 0 to 28. The - number is stored in the following format: - Low 96 bits are the significand, as a 96-bit unsigned - integer (all 96-bit values are allowed, up to (2 96 - -1)). - Next 16 bits are unused. - Next 8 - bits are the scale, stored as an 8-bit unsigned integer. - Next 7 bits are unused. - If the highest bit is - one, it's a negative number. - - The elements described above are in the same order as the - order of each bit of each element, that is, either most significant - first or least significant first. - - - - A not-a-number value. - - - Negative infinity, less than any other number. - - - Represents the number negative zero. - - - Represents the number 1. - - - Positive infinity, greater than any other - number. - - - A not-a-number value that signals an invalid operation - flag when it's passed as an argument to any arithmetic operation in - arbitrary-precision decimal. - - - Represents the number 10. - - - Represents the number 0. - - - Creates a copy of this arbitrary-precision binary - number. - An arbitrary-precision decimal floating-point - number. - - - Gets this object's exponent. This object's value will be - an integer if the exponent is positive or zero. - This object's exponent. This object's value will be an - integer if the exponent is positive or zero. - - - Gets a value indicating whether this object is finite (not - infinity or NaN). - true if this object is finite (not infinity or NaN); - otherwise, false. - - - Gets a value indicating whether this object is negative, - including negative zero. - true if this object is negative, including negative - zero; otherwise, false. - - - Gets a value indicating whether this object's value equals - 0. - true if this object's value equals 0; otherwise, - false. true if this object's value equals 0; - otherwise, false. - - - Returns whether this object's value is an - integer. - true if this object's value is an integer; - otherwise, false. - - - Gets this object's unscaled value, or significand, and - makes it negative if this object is negative. If this value is - not-a-number (NaN), that value's absolute value is the NaN's - "payload" (diagnostic information). - This object's unscaled value. Will be negative if this - object's value is negative (including a negative NaN). - - - Gets this value's sign: -1 if negative; 1 if positive; 0 - if zero. - This value's sign: -1 if negative; 1 if positive; 0 if - zero. - - - Gets the absolute value of this object's unscaled value, - or significand. If this value is not-a-number (NaN), that value is - the NaN's "payload" (diagnostic information). - The absolute value of this object's unscaled value. - - - Returns a number with the value - exponent*10^significand. - Desired value for the - significand. - Desired value for the exponent. - An arbitrary-precision decimal number. - - - Creates a number with the value - exponent*10^significand. - Desired value for the significand. - Desired value for the exponent. - An arbitrary-precision decimal number. - The parameter is null. - - - Creates a number with the value - exponent*10^significand. - Desired value for the significand. - Desired value for the exponent. - An arbitrary-precision decimal number. - The parameter is null. - - - Creates a number with the value - exponent*10^significand. - Desired value for the significand. - Desired value for the exponent. - An arbitrary-precision decimal number. - The parameter or is - null. - - - Creates a number with the value - exponent*10^significand. - Desired value for the - significand. - Desired value for the exponent. - An arbitrary-precision decimal number. - - - Creates a number with the value - exponent*10^significand. - Desired value for the - significand. - Desired value for the exponent. - An arbitrary-precision decimal number. - - - Creates a not-a-number arbitrary-precision decimal - number. - An integer, 0 or greater, to use as diagnostic - information associated with this object. If none is needed, should - be zero. To get the diagnostic information from another - arbitrary-precision decimal floating-point number, use that - object's UnsignedMantissa property. - A quiet not-a-number. - - - Creates a not-a-number arbitrary-precision decimal - number. - An integer, 0 or greater, to use as diagnostic - information associated with this object. If none is needed, should - be zero. To get the diagnostic information from another - arbitrary-precision decimal floating-point number, use that - object's UnsignedMantissa property. - Whether the return value will be signaling - (true) or quiet (false). - Whether the return value is - negative. - An arithmetic context to control the precision - (in decimal digits) of the diagnostic information. The rounding and - exponent range of this context will be ignored. Can be null. The - only flag that can be signaled in this context is FlagInvalid, - which happens if diagnostic information needs to be truncated and - too much memory is required to do so. - An arbitrary-precision decimal number. - The parameter is null or is less than 0. - - - Creates an arbitrary-precision decimal number from a - 64-bit binary floating-point number. This method computes the exact - value of the floating point number, not an approximation, as is - often the case by converting the floating point number to a string - first. Remember, though, that the exact value of a 64-bit binary - floating-point number is not always the value that results when - passing a literal decimal number (for example, calling - EDecimal.FromDouble(0.1) ), since not all decimal numbers - can be converted to exact binary numbers (in the example given, the - resulting arbitrary-precision decimal will be the value of the - closest "double" to 0.1, not 0.1 exactly). To create an - arbitrary-precision decimal number from a decimal value, use - FromString instead in most cases (for example: - EDecimal.FromString("0.1") ). - The parameter is a 64-bit - floating-point number. - An arbitrary-precision decimal number with the same value - as . - - - Creates an arbitrary-precision decimal number from a - 64-bit binary floating-point number, encoded in the IEEE 754 - binary64 format. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the floating point number to a string first. - Remember, though, that the exact value of a 64-bit binary - floating-point number is not always the value that results when - passing a literal decimal number, since not all decimal numbers can - be converted to exact binary numbers (in the example given, the - resulting arbitrary-precision decimal will be the value of the - closest "double" to 0.1, not 0.1 exactly). To create an - arbitrary-precision decimal number from a decimal value, use - FromString instead in most cases. - The parameter is a - 64-bit signed integer. - An arbitrary-precision decimal number with the same value - as . - - - Converts an arbitrary-precision integer to an arbitrary - precision decimal. - An arbitrary-precision integer. - An arbitrary-precision decimal number with the exponent - set to 0. - - - Converts an arbitrary-precision binary floating-point - number to an arbitrary precision decimal. - An arbitrary-precision binary floating-point - number. - An arbitrary-precision decimal number. - - - Creates an arbitrary-precision decimal number from an - arbitrary-precision binary floating-point number. - An arbitrary-precision binary floating-point - number. - An arbitrary-precision decimal number. - The parameter is null. - - - Converts a boolean value (true or false) to an - arbitrary-precision decimal number. - Either true or false. - The number 1 if is true; - otherwise, 0. - - - Creates an arbitrary-precision decimal number from a - 32-bit signed integer. - The parameter is a 32-bit signed integer. - An arbitrary-precision decimal number with the exponent - set to 0. - - - Converts an unsigned integer expressed as a 64-bit signed - integer to an arbitrary-precision decimal number. - A 64-bit signed integer. If this value is - 0 or greater, the return value will represent it. If this value is - less than 0, the return value will store 2^64 plus this value - instead. - An arbitrary-precision decimal number with the exponent - set to 0. If is 0 or greater, the - return value will represent it. If - is less than 0, the return value will store 2^64 plus this value - instead. - - - Creates an arbitrary-precision decimal number from a - 64-bit signed integer. - The parameter is a 64-bit signed integer. - This number's value as an arbitrary-precision decimal - number with the exponent set to 0. - - - Creates an arbitrary-precision decimal number from a - 32-bit binary floating-point number. This method computes the exact - value of the floating point number, not an approximation, as is - often the case by converting the floating point number to a string - first. Remember, though, that the exact value of a 32-bit binary - floating-point number is not always the value that results when - passing a literal decimal number (for example, calling - EDecimal.FromSingle(0.1f) ), since not all decimal numbers - can be converted to exact binary numbers (in the example given, the - resulting arbitrary-precision decimal will be the the value of the - closest "float" to 0.1, not 0.1 exactly). To create an - arbitrary-precision decimal number from a decimal value, use - FromString instead in most cases (for example: - EDecimal.FromString("0.1") ). - The parameter is a 32-bit - binary floating-point number. - An arbitrary-precision decimal number with the same value - as . - - - Creates an arbitrary-precision decimal number from a - 32-bit binary floating-point number encoded in the IEEE 754 - binary32 format. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the floating point number to a string first. - Remember, though, that the exact value of a 32-bit binary - floating-point number is not always the value that results when - passing a literal decimal number, since not all decimal numbers can - be converted to exact binary numbers (in the example given, the - resulting arbitrary-precision decimal will be the the value of the - closest "float" to 0.1, not 0.1 exactly). To create an - arbitrary-precision decimal number from a decimal value, use - FromString instead in most cases. - A 32-bit binary floating-point number encoded - in the IEEE 754 binary32 format. - An arbitrary-precision decimal number with the same value - as . - - - Creates an arbitrary-precision decimal number from a - sequence of char s that represents a number. See - FromString(String, int, int, EContext) for more information. - Note that calling the overload that takes an EContext is often much - faster than creating the EDecimal then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - A sequence that represents a number. - An arbitrary-precision decimal number with the same value - as the given sequence of char s. - The parameter is not a correctly formatted number - sequence. - - - Creates an arbitrary-precision decimal number from a - sequence of char s that represents a number. See - FromString(String, int, int, EContext) for more - information. - A sequence of char s that represents a - number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. Note that providing a context is often much faster - than creating the EDecimal without a context then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - An arbitrary-precision decimal number with the same value - as the given sequence of char s. - The parameter is null. - - - Creates an arbitrary-precision decimal number from a - sequence of char s that represents a number. See - FromString(String, int, int, EContext) for more information. - Note that calling the overload that takes an EContext is often much - faster than creating the EDecimal then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - A sequence that represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision decimal number with the same value - as the given sequence of char s. - The parameter is not a correctly formatted number - sequence. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - - Creates an arbitrary-precision decimal number from a sequence - of char s that represents a number. - The format of the sequence generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if the minus sign, the value is negative.) - One or more digits, with a single optional decimal point - (".", U+002E) before or after those digits or between two of them. - These digits may begin with any number of zeros. - Optionally, "E"/"e" followed by an optional (positive - exponent) or "-" (negative exponent) and followed by one or more - digits specifying the exponent (these digits may begin with any - number of zeros). - The sequence can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN" /"-NaN") followed by any number of digits - (these digits may begin with any number of zeros), or signaling NaN - ("sNaN" /"-sNaN") followed by any number of digits (these digits - may begin with any number of zeros), all where the letters can be - any combination of basic upper-case and/or basic lower-case - letters. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The sequence is not - allowed to contain white space characters, including - spaces. - A sequence of char s, a portion of which - represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. Note that providing a context is often much faster - than creating the EDecimal without a context then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - An arbitrary-precision decimal number with the same value - as the given sequence of char s. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Creates an arbitrary-precision decimal number from a - sequence of bytes (interpreted as text) that represents a number. - See FromString(String, int, int, EContext) for more - information. Note that calling the overload that takes an EContext - is often much faster than creating the EDecimal then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - A sequence that represents a number. - An arbitrary-precision decimal number with the same value - as the given sequence of bytes (interpreted as text). - The parameter is not a correctly formatted number - sequence. - - - Creates an arbitrary-precision decimal number from a - sequence of bytes (interpreted as text) that represents a number. - See FromString(String, int, int, EContext) for more - information. - A sequence of bytes (interpreted as text) that - represents a number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. Note that providing a context is often much faster - than creating the EDecimal without a context then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - An arbitrary-precision decimal number with the same value - as the given sequence of bytes (interpreted as text). - The parameter is null. - - - Creates an arbitrary-precision decimal number from a - sequence of bytes (interpreted as text) that represents a number. - See FromString(String, int, int, EContext) for more - information. Note that calling the overload that takes an EContext - is often much faster than creating the EDecimal then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - A sequence that represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in bytes, of the desired portion - of (but not more than 's length). - An arbitrary-precision decimal number with the same value - as the given sequence of bytes (interpreted as text). - The parameter is not a correctly formatted number - sequence. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - - Creates an arbitrary-precision decimal number from a sequence - of bytes (interpreted as text) that represents a number. Each byte - in the sequence has to be a code point in the Basic Latin range - (0x00 to 0x7f or U+0000 to U+007F) of the Unicode Standard. - The format of the sequence generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if the minus sign, the value is negative.) - One or more digits, with a single optional decimal point - (".", U+002E) before or after those digits or between two of them. - These digits may begin with any number of zeros. - Optionally, "E"/"e" followed by an optional (positive - exponent) or "-" (negative exponent) and followed by one or more - digits specifying the exponent (these digits may begin with any - number of zeros). - The sequence can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN" /"-NaN") followed by any number of digits - (these digits may begin with any number of zeros), or signaling NaN - ("sNaN" /"-sNaN") followed by any number of digits (these digits - may begin with any number of zeros), all where the letters can be - any combination of basic upper-case and/or basic lower-case - letters. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The sequence is not - allowed to contain white space characters, including - spaces. - A sequence of bytes (interpreted as text), a - portion of which represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. Note that providing a context is often much faster - than creating the EDecimal without a context then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - An arbitrary-precision decimal number with the same value - as the given sequence of bytes (interpreted as text). - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Creates an arbitrary-precision decimal number from a text - string that represents a number. See FromString(String, int, - int, EContext) for more information. Note that calling the - overload that takes an EContext is often much faster than creating - the EDecimal then calling RoundToPrecision on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - A string that represents a number. - An arbitrary-precision decimal number with the same value - as the given string. - The parameter is not a correctly formatted number - string. - - - Creates an arbitrary-precision decimal number from a text - string that represents a number. See FromString(String, int, - int, EContext) for more information. - A string that represents a number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. Note that providing a context is often much faster - than creating the EDecimal without a context then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - An arbitrary-precision decimal number with the same value - as the given string. - The parameter is null. - - - Creates an arbitrary-precision decimal number from a text - string that represents a number. See FromString(String, int, - int, EContext) for more information. Note that calling the - overload that takes an EContext is often much faster than creating - the EDecimal then calling RoundToPrecision on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - A string that represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision decimal number with the same value - as the given string. - The parameter is not a correctly formatted number - string. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - - Creates an arbitrary-precision decimal number from a text - string that represents a number. - The format of the string generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if the minus sign, the value is negative.) - One or more digits, with a single optional decimal point - (".", U+002E) before or after those digits or between two of them. - These digits may begin with any number of zeros. - Optionally, "E"/"e" followed by an optional (positive - exponent) or "-" (negative exponent) and followed by one or more - digits specifying the exponent (these digits may begin with any - number of zeros). - The string can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN" /"-NaN") followed by any number of digits - (these digits may begin with any number of zeros), or signaling NaN - ("sNaN" /"-sNaN") followed by any number of digits (these digits - may begin with any number of zeros), all where the letters can be - any combination of basic upper-case and/or basic lower-case - letters. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The string is not - allowed to contain white space characters, including - spaces. - A text string, a portion of which represents a - number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. Note that providing a context is often much faster - than creating the EDecimal without a context then calling - RoundToPrecision on that EDecimal, especially if the context - specifies a precision limit and exponent range. - An arbitrary-precision decimal number with the same value - as the given string. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - Gets the greater value between two decimal - numbers. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The larger value of the two numbers. If one is positive - zero and the other is negative zero, returns the positive zero. If - the two numbers are positive and have the same value, returns the - one with the larger exponent. If the two numbers are negative and - have the same value, returns the one with the smaller - exponent. - The parameter or is null. - - - Gets the greater value between two decimal - numbers. - An arbitrary-precision decimal number. - Another arbitrary-precision decimal - number. - The larger value of the two numbers. If one is positive - zero and the other is negative zero, returns the positive zero. If - the two numbers are positive and have the same value, returns the - one with the larger exponent. If the two numbers are negative and - have the same value, returns the one with the smaller - exponent. - The parameter or is null. - - - Gets the greater value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Max. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The larger value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the greater value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Max. - The first value to compare. - The second value to compare. - The larger value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the lesser value between two decimal - numbers. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The smaller value of the two numbers. If one is positive - zero and the other is negative zero, returns the negative zero. If - the two numbers are positive and have the same value, returns the - one with the smaller exponent. If the two numbers are negative and - have the same value, returns the one with the larger - exponent. - The parameter or is null. - - - Gets the lesser value between two decimal - numbers. - The first value to compare. - The second value to compare. - The smaller value of the two numbers. If one is positive - zero and the other is negative zero, returns the negative zero. If - the two numbers are positive and have the same value, returns the - one with the smaller exponent. If the two numbers are negative and - have the same value, returns the one with the larger - exponent. - The parameter or is null. - - - Gets the lesser value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Min. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The smaller value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the lesser value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Min. - The first value to compare. - The second value to compare. - The smaller value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Finds the constant π, the circumference of a circle - divided by its diameter. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as π can never be represented - exactly.. - The constant π rounded to the given precision. Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Finds the absolute value of this object (if it's negative, - it becomes positive). - An arbitrary-precision decimal number. Returns signaling - NaN if this value is signaling NaN. (In this sense, this method is - similar to the "copy-abs" operation in the General Decimal - Arithmetic Specification, except this method does not necessarily - return a copy of this object.). - - - Returns a number with the same value as this one, but - copying the sign (positive or negative) of another number. (This - method is similar to the "copy-sign" operation in the General - Decimal Arithmetic Specification, except this method does not - necessarily return a copy of this object.). - A number whose sign will be copied. - An arbitrary-precision decimal number. - The parameter is null. - - - Finds the absolute value of this object (if it's negative, - it becomes positive). - An arithmetic context to control the - precision, rounding, and exponent range of the result. If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the precision is - unlimited and no rounding is needed. - The absolute value of this object. Signals FlagInvalid and - returns quiet NaN if this value is signaling NaN. - - - Adds this arbitrary-precision decimal floating-point - number and another arbitrary-precision decimal floating-point - number and returns the result. The exponent for the result is the - lower of this arbitrary-precision decimal floating-point number's - exponent and the other arbitrary-precision decimal floating-point - number's exponent. - An arbitrary-precision decimal - number. - The sum of the two numbers, that is, this - arbitrary-precision decimal floating-point number plus another - arbitrary-precision decimal floating-point number. If this - arbitrary-precision decimal floating-point number is not-a-number - (NaN), returns NaN. - - - Adds this arbitrary-precision decimal floating-point - number and another arbitrary-precision decimal floating-point - number and returns the result. - The number to add to. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The sum of the two numbers, that is, this - arbitrary-precision decimal floating-point number plus another - arbitrary-precision decimal floating-point number. If this - arbitrary-precision decimal floating-point number is not-a-number - (NaN), returns NaN. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - An arbitrary-precision decimal number. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value or if is null, or 0 if both - values are equal. - This implementation returns a positive number if 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.. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - The parameter is - a 32-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object is a quiet NaN or signaling NaN, this method - will not trigger an error. Instead, NaN will compare greater than - any other number, including infinity. - The parameter is - a 32-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - The parameter is - a 64-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object is a quiet NaN or signaling NaN, this method - will not trigger an error. Instead, NaN will compare greater than - any other number, including infinity. - The parameter is - a 64-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object or the other object is a quiet NaN or - signaling NaN, this method will not trigger an error. Instead, NaN - will compare greater than any other number, including infinity. Two - different NaN values will be considered equal. - An arbitrary-precision decimal number. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value or if is null, or 0 if both - values are equal. - This implementation returns a positive number if 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.. - - - Compares an arbitrary-precision binary floating-point - number with this instance. - The other object to compare. Can be - null. - Zero if the values are equal; a negative number if this - instance is less; or a positive number if this instance is greater. - Returns 0 if both values are NaN (even signaling NaN) and 1 if this - value is NaN (even signaling NaN) and the other isn't, or if the - other value is null. - This implementation returns a positive number if 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.. - - - Compares the mathematical values of this object and - another object, treating quiet NaN as signaling. - In this method, negative zero and positive zero are - considered equal. - If this object or the other object is a quiet NaN or - signaling NaN, this method will return a quiet NaN and will signal - a FlagInvalid flag. - An arbitrary-precision decimal number. - An arithmetic context. The precision, rounding, - and exponent range are ignored. If HasFlags of the context - is true, will store the flags resulting from the operation (the - flags are in addition to the pre-existing flags). Can be - null. - Quiet NaN if this object or the other object is NaN, or 0 - if both objects have the same value, or -1 if this object is less - than the other value, or a 1 if this object is greater. - This implementation returns a positive number if 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.. - - - Compares the absolute values of this object and another - object, imposing a total ordering on all possible values (ignoring - their signs). In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero and positive zero are considered equal. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - An arbitrary-precision decimal number to - compare with this one. - The number 0 if both objects have the same value (ignoring - their signs), or -1 if this object is less than the other value - (ignoring their signs), or 1 if this object is greater (ignoring - their signs). - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values. In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision decimal number to - compare with this one. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. Does not signal flags if either value is signaling NaN. - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values (ignoring their - signs). In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision decimal number to - compare with this one. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects have the same value (ignoring - their signs), or -1 if this object is less than the other value - (ignoring their signs), or 1 if this object is greater (ignoring - their signs). Does not signal flags if either value is signaling - NaN. - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values. In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision decimal number to - compare with this one. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. - This implementation returns a positive number if 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.. - - - Compares the mathematical values of this object and - another object. - In this method, negative zero and positive zero are - considered equal. - If this object or the other object is a quiet NaN or - signaling NaN, this method returns a quiet NaN, and will signal a - FlagInvalid flag if either is a signaling NaN. - An arbitrary-precision decimal number. - An arithmetic context. The precision, rounding, - and exponent range are ignored. If HasFlags of the context - is true, will store the flags resulting from the operation (the - flags are in addition to the pre-existing flags). Can be - null. - Quiet NaN if this object or the other object is NaN, or 0 - if both objects have the same value, or -1 if this object is less - than the other value, or 1 if this object is greater. - This implementation returns a positive number if 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.. - - - Divides this arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns the result; returns NaN instead if the result would - have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, - 2/3, and so on); if this is not desired, use DivideToExponent, or - use the Divide overload that takes an EContext. - The number to divide by. - The result of dividing this arbitrary-precision decimal - floating-point number by another arbitrary-precision decimal - floating-point number. Returns infinity if the divisor (this - arbitrary-precision decimal floating-point number) is 0 and the - dividend (the other arbitrary-precision decimal floating-point - number) is nonzero. Returns not-a-number (NaN) if the divisor and - the dividend are 0. Returns NaN if the result can't be exact - because it would have a nonterminating binary expansion (examples - include 1 divided by any multiple of 3, such as 1/3 or 1/12). If - this is not desired, use DivideToExponent instead, or use the - Divide overload that takes an EContext (such as - EContext.Decimal128 ) instead. - - - Divides this arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns the result. - The number to divide by. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The result of dividing this arbitrary-precision decimal - floating-point number by another arbitrary-precision decimal - floating-point number. Signals FlagDivideByZero and returns - infinity if the divisor (this arbitrary-precision decimal - floating-point number) is 0 and the dividend (the other - arbitrary-precision decimal floating-point number) is nonzero. - Signals FlagInvalid and returns not-a-number (NaN) if the divisor - and the dividend are 0; or, either is null - or 's precision is 0, and the result would - have a nonterminating decimal expansion (examples include 1 divided - by any multiple of 3, such as 1/3 or 1/12); or, the rounding mode - is ERounding.None and the result is not exact. - - - Calculates the quotient and remainder using the - DivideToIntegerNaturalScale and the formula in - RemainderNaturalScale. - The number to divide by. - A 2 element array consisting of the quotient and remainder - in that order. - - - Calculates the quotient and remainder using the - DivideToIntegerNaturalScale and the formula in - RemainderNaturalScale. - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only in the division portion of the remainder - calculation; as a result, it's possible for the remainder to have a - higher precision than given in this context. Flags will be set on - the given context only if the context's HasFlags is true and - the integer part of the division result doesn't fit the precision - and exponent range without rounding. Can be null, in which the - precision is unlimited and no additional rounding, other than the - rounding down to an integer after division, is needed. - A 2 element array consisting of the quotient and remainder - in that order. - - - Divides this arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns a two-item array containing the result of the division - and the remainder, in that order. The result of division is - calculated as though by DivideToIntegerNaturalScale, and - the remainder is calculated as though by - RemainderNaturalScale. - The number to divide by. - An array of two items: the first is the result of the - division as an arbitrary-precision decimal floating-point number, - and the second is the remainder as an arbitrary-precision decimal - floating-point number. The result of division is the result of the - method on the two operands, and the remainder is the result of the - Remainder method on the two operands. - - - Divides this arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns a two-item array containing the result of the division - and the remainder, in that order. The result of division is - calculated as though by DivideToIntegerNaturalScale, and - the remainder is calculated as though by - RemainderNaturalScale. - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only in the division portion of the remainder - calculation; as a result, it's possible for the remainder to have a - higher precision than given in this context. Flags will be set on - the given context only if the context's HasFlags is true and - the integer part of the division result doesn't fit the precision - and exponent range without rounding. Can be null, in which the - precision is unlimited and no additional rounding, other than the - rounding down to an integer after division, is needed. - An array of two items: the first is the result of the - division as an arbitrary-precision decimal floating-point number, - and the second is the remainder as an arbitrary-precision decimal - floating-point number. The result of division is the result of the - method on the two operands, and the remainder is the result of the - Remainder method on the two operands. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent to the result. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - An arithmetic context object to control the - rounding mode to use if the result must be scaled down to have the - same exponent as this value. If the precision given in the context - is other than 0, calls the Quantize method with both arguments - equal to the result of the operation (and can signal FlagInvalid - and return NaN if the result doesn't fit the given precision). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the default - rounding mode is HalfEven. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the context defines an exponent range and the - desired exponent is outside that range. Signals FlagInvalid and - returns not-a-number (NaN) if the rounding mode is ERounding.None - and the result is not exact. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent (expressed as a 32-bit signed integer) to the - result, using the half-even rounding mode. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - An arithmetic context object to control the - rounding mode to use if the result must be scaled down to have the - same exponent as this value. If the precision given in the context - is other than 0, calls the Quantize method with both arguments - equal to the result of the operation (and can signal FlagInvalid - and return NaN if the result doesn't fit the given precision). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the default - rounding mode is HalfEven. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the context defines an exponent range and the - desired exponent is outside that range. Signals FlagInvalid and - returns not-a-number (NaN) if the rounding mode is ERounding.None - and the result is not exact. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent to the result. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent (expressed as a 32-bit signed integer) to the - result, using the half-even rounding mode. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent to the result. - The number to divide by. - The desired exponent. A negative number - places the cutoff point to the right of the usual decimal point (so - a negative number means the number of decimal places to round to). - A positive number places the cutoff point to the left of the usual - decimal point. - An arithmetic context object to control the - rounding mode to use if the result must be scaled down to have the - same exponent as this value. If the precision given in the context - is other than 0, calls the Quantize method with both arguments - equal to the result of the operation (and can signal FlagInvalid - and return NaN if the result doesn't fit the given precision). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the default - rounding mode is HalfEven. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the context defines an exponent range and the - desired exponent is outside that range. Signals FlagInvalid and - returns not-a-number (NaN) if the rounding mode is ERounding.None - and the result is not exact. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent to the result, using the half-even rounding - mode. - The number to divide by. - The desired exponent. A negative number - places the cutoff point to the right of the usual decimal point (so - a negative number means the number of decimal places to round to). - A positive number places the cutoff point to the left of the usual - decimal point. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent (expressed as a 64-bit signed integer) to the - result, using the half-even rounding mode. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent (expressed as a 32-bit signed integer) to the - result, using the half-even rounding mode. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. - - - Divides two arbitrary-precision decimal numbers, and gives - a particular exponent to the result. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual decimal - point (so a negative number means the number of decimal places to - round to). A positive number places the cutoff point to the left of - the usual decimal point. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Returns not-a-number (NaN) if the divisor and the dividend - are 0. Returns NaN if the rounding mode is ERounding.None and the - result is not exact. - - - Divides two arbitrary-precision decimal numbers, and - returns the integer part of the result, rounded down, with the - preferred exponent set to this value's exponent minus the divisor's - exponent. - The number to divide by. - The integer part of the quotient of the two objects. - Signals FlagDivideByZero and returns infinity if the divisor is 0 - and the dividend is nonzero. Signals FlagInvalid and returns - not-a-number (NaN) if the divisor and the dividend are 0. - - - Divides this object by another object, and returns the - integer part of the result (which is initially rounded down), with - the preferred exponent set to this value's exponent minus the - divisor's exponent. - The parameter is - an arbitrary-precision decimal floating-point number. - The parameter is an - EContext object. - The integer part of the quotient of the two objects. - Signals FlagInvalid and returns not-a-number (NaN) if the return - value would overflow the exponent range. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Divides this object by another object, and returns the - integer part of the result, with the exponent set to 0. - The number to divide by. - An arithmetic context object to control the - precision. The rounding and exponent range settings of this context - are ignored. If HasFlags of the context is true, will also - store the flags resulting from the operation (the flags are in - addition to the pre-existing flags). Can be null, in which case the - precision is unlimited. - The integer part of the quotient of the two objects. The - exponent will be set to 0. Signals FlagDivideByZero and returns - infinity if the divisor is 0 and the dividend is nonzero. Signals - FlagInvalid and returns not-a-number (NaN) if the divisor and the - dividend are 0, or if the result doesn't fit the given - precision. - - - Divides this object by another decimal number and returns - a result with the same exponent as this object (the - dividend). - The number to divide by. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two numbers. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Determines whether this object's significand, exponent, - and properties are equal to those of another object. Not-a-number - values are considered equal if the rest of their properties are - equal. - An arbitrary-precision decimal number. - true if this object's significand and exponent are - equal to those of another object; otherwise, false. - - - Determines whether this object's significand, exponent, - and properties are equal to those of another object and that other - object is an arbitrary-precision decimal number. Not-a-number - values are considered equal if the rest of their properties are - equal. - The parameter is an - arbitrary object. - true if the objects are equal; otherwise, - false. In this method, two objects are not equal if they - don't have the same type or if one is null and the other - isn't. - - - Finds e (the base of natural logarithms) raised to the - power of this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the exponential function's - results are generally not exact. (Unlike in the General Decimal - Arithmetic Specification, any rounding mode is allowed.). - Exponential of this object. If this object's value is 1, - returns an approximation to " e" within the given precision. - Signals FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Finds e (the base of natural logarithms) raised to the - power of this object's value, and subtracts the result by 1 and - returns the final result, in a way that avoids loss of precision if - the true result is very close to 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the exponential function's - results are generally not exact. (Unlike in the General Binary - Arithmetic Specification, any rounding mode is allowed.). - Exponential of this object, minus 1. Signals FlagInvalid - and returns not-a-number (NaN) if the parameter is null or the precision is unlimited (the context's - Precision property is 0). - - - Calculates this object's hash code. No application or - process IDs are used in the hash code calculation. - A 32-bit signed integer. - - - Gets a value indicating whether this object is positive or - negative infinity. - true if this object is positive or negative - infinity; otherwise, false. - - - Gets a value indicating whether this object is not a - number (NaN). - true if this object is not a number (NaN); - otherwise, false. - - - Returns whether this object is negative - infinity. - true if this object is negative infinity; - otherwise, false. - - - Returns whether this object is positive - infinity. - true if this object is positive infinity; - otherwise, false. - - - Gets a value indicating whether this object is a quiet - not-a-number value. - true if this object is a quiet not-a-number value; - otherwise, false. - - - Gets a value indicating whether this object is a signaling - not-a-number value. - true if this object is a signaling not-a-number - value; otherwise, false. - - - Finds the natural logarithm of this object, that is, the - power (exponent) that e (the base of natural logarithms) must be - raised to in order to equal this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the ln function's results are - generally not exact. (Unlike in the General Decimal Arithmetic - Specification, any rounding mode is allowed.). - Ln(this object). Signals the flag FlagInvalid and returns - NaN if this object is less than 0 (the result would be a complex - number with a real part equal to Ln of this object's absolute value - and an imaginary part equal to pi, but the return value is still - NaN.). Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null or the precision is - unlimited (the context's Precision property is 0). Signals no flags - and returns negative infinity if this object's value is - 0. - - - Finds the base-10 logarithm of this object, that is, the - power (exponent) that the number 10 must be raised to in order to - equal this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the ln function's results are - generally not exact. (Unlike in the General Decimal Arithmetic - Specification, any rounding mode is allowed.). - Ln(this object)/Ln(10). Signals the flag FlagInvalid and - returns not-a-number (NaN) if this object is less than 0. Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Adds 1 to this object's value and finds the natural - logarithm of the result, in a way that avoids loss of precision - when this object's value is between 0 and 1. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the ln function's results are - generally not exact. (Unlike in the General Binary Arithmetic - Specification, any rounding mode is allowed.). - Ln(1+(this object)). Signals the flag FlagInvalid and - returns NaN if this object is less than -1 (the result would be a - complex number with a real part equal to Ln of 1 plus this object's - absolute value and an imaginary part equal to pi, but the return - value is still NaN.). Signals FlagInvalid and returns not-a-number - (NaN) if the parameter is null or the - precision is unlimited (the context's Precision property is 0). - Signals no flags and returns negative infinity if this object's - value is 0. - - - Finds the base-N logarithm of this object, that is, the - power (exponent) that the number N must be raised to in order to - equal this object's value. - The parameter - is a Numbers.EDecimal object. - The parameter is a - Numbers.EContext object. - Ln(this object)/Ln(baseValue). Signals the flag - FlagInvalid and returns not-a-number (NaN) if this object is less - than 0. Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null or the precision is - unlimited (the context's Precision property is 0). - The parameter is null. - - - Returns a number similar to this number but with the - decimal point moved to the left. - The number of decimal places to move the - decimal point to the left. If this number is negative, instead - moves the decimal point to the right by this number's absolute - value. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the left. - The number of decimal places to move the - decimal point to the left. If this number is negative, instead - moves the decimal point to the right by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the left. - The number of decimal places to move the - decimal point to the left. If this number is negative, instead - moves the decimal point to the right by this number's absolute - value. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the left. - The number of decimal places to move the - decimal point to the left. If this number is negative, instead - moves the decimal point to the right by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the right. - The number of decimal places to move the - decimal point to the right. If this number is negative, instead - moves the decimal point to the left by this number's absolute - value. - A number whose exponent is increased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the right. - The number of decimal places to move the - decimal point to the right. If this number is negative, instead - moves the decimal point to the left by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is increased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the right. - The number of decimal places to move the - decimal point to the right. If this number is negative, instead - moves the decimal point to the left by this number's absolute - value. - A number whose exponent is increased by , but not to more than 0. - - - Returns a number similar to this number but with the - decimal point moved to the right. - The number of decimal places to move the - decimal point to the right. If this number is negative, instead - moves the decimal point to the left by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is increased by , but not to more than 0. - - - Multiplies this arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns the result. The exponent for the result is this - arbitrary-precision decimal floating-point number's exponent plus - the other arbitrary-precision decimal floating-point number's - exponent. - Another decimal number. - The product of the two numbers, that is, this - arbitrary-precision decimal floating-point number times another - arbitrary-precision decimal floating-point number. - The parameter is null. - - - Multiplies this arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns the result. - Another decimal number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The product of the two numbers, that is, this - arbitrary-precision decimal floating-point number times another - arbitrary-precision decimal floating-point number. - - - Adds this arbitrary-precision decimal floating-point - number and a 64-bit signed integer and returns the result. The - exponent for the result is the lower of this arbitrary-precision - decimal floating-point number's exponent and the other 64-bit - signed integer's exponent. - The parameter - is a 64-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision decimal floating-point number plus a 64-bit - signed integer. If this arbitrary-precision decimal floating-point - number is not-a-number (NaN), returns NaN. - - - Subtracts a 64-bit signed integer from this - arbitrary-precision decimal floating-point number and returns the - result. The exponent for the result is the lower of this - arbitrary-precision decimal floating-point number's exponent and - the other 64-bit signed integer's exponent. - The parameter - is a 64-bit signed integer. - The difference between the two numbers, that is, this - arbitrary-precision decimal floating-point number minus a 64-bit - signed integer. If this arbitrary-precision decimal floating-point - number is not-a-number (NaN), returns NaN. - - - Multiplies this arbitrary-precision decimal floating-point - number by a 64-bit signed integer and returns the result. The - exponent for the result is this arbitrary-precision decimal - floating-point number's exponent plus the other 64-bit signed - integer's exponent. - The parameter - is a 64-bit signed integer. - The product of the two numbers, that is, this - arbitrary-precision decimal floating-point number times a 64-bit - signed integer. - - - Divides this arbitrary-precision decimal floating-point - number by a 64-bit signed integer and returns the result; returns - NaN instead if the result would have a nonterminating decimal - expansion (including 1/3, 1/12, 1/7, 2/3, and so on); if this is - not desired, use DivideToExponent, or use the Divide overload that - takes an EContext. - The parameter - is a 64-bit signed integer. - The result of dividing this arbitrary-precision decimal - floating-point number by a 64-bit signed integer. Returns infinity - if the divisor (this arbitrary-precision decimal floating-point - number) is 0 and the dividend (the other 64-bit signed integer) is - nonzero. Returns not-a-number (NaN) if the divisor and the dividend - are 0. Returns NaN if the result can't be exact because it would - have a nonterminating binary expansion (examples include 1 divided - by any multiple of 3, such as 1/3 or 1/12). If this is not desired, - use DivideToExponent instead, or use the Divide overload that takes - an EContext (such as EContext.Decimal128 ) - instead. - - - Adds this arbitrary-precision decimal floating-point - number and a 32-bit signed integer and returns the result. The - exponent for the result is the lower of this arbitrary-precision - decimal floating-point number's exponent and the other 32-bit - signed integer's exponent. - A 32-bit signed integer to add to this - object. - The sum of the two numbers, that is, this - arbitrary-precision decimal floating-point number plus a 32-bit - signed integer. If this arbitrary-precision decimal floating-point - number is not-a-number (NaN), returns NaN. - - - Subtracts a 32-bit signed integer from this - arbitrary-precision decimal floating-point number and returns the - result. The exponent for the result is the lower of this - arbitrary-precision decimal floating-point number's exponent and - the other 32-bit signed integer's exponent. - A 32-bit signed integer to subtract from - this object. - The difference between the two numbers, that is, this - arbitrary-precision decimal floating-point number minus a 32-bit - signed integer. If this arbitrary-precision decimal floating-point - number is not-a-number (NaN), returns NaN. - - - Multiplies this arbitrary-precision decimal floating-point - number by a 32-bit signed integer and returns the result. The - exponent for the result is this arbitrary-precision decimal - floating-point number's exponent plus the other 32-bit signed - integer's exponent. - A 32-bit signed integer to multiply this - object by. - The product of the two numbers, that is, this - arbitrary-precision decimal floating-point number times a 32-bit - signed integer. - - - Divides this arbitrary-precision decimal floating-point - number by a 32-bit signed integer and returns the result; returns - NaN instead if the result would have a nonterminating decimal - expansion (including 1/3, 1/12, 1/7, 2/3, and so on); if this is - not desired, use DivideToExponent, or use the Divide overload that - takes an EContext. - A 32-bit signed integer, the divisor, to - divide this object by. - The result of dividing this arbitrary-precision decimal - floating-point number by a 32-bit signed integer. Returns infinity - if the divisor (this arbitrary-precision decimal floating-point - number) is 0 and the dividend (the other 32-bit signed integer) is - nonzero. Returns not-a-number (NaN) if the divisor and the dividend - are 0. Returns NaN if the result can't be exact because it would - have a nonterminating binary expansion (examples include 1 divided - by any multiple of 3, such as 1/3 or 1/12). If this is not desired, - use DivideToExponent instead, or use the Divide overload that takes - an EContext (such as EContext.Decimal128 ) - instead. - - - Multiplies by one decimal number, and then adds another - decimal number. - The value to multiply. - The value to add. - An arbitrary-precision decimal floating-point - number. - - - Multiplies by one value, and then adds another - value. - The value to multiply. - The value to add. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. If the precision doesn't indicate a simplified - arithmetic, rounding and precision/exponent adjustment is done only - once, namely, after multiplying and adding. - The result thisValue * multiplicand + augend. - - - Multiplies by one value, and then subtracts another - value. - The value to multiply. - The value to subtract. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. If the precision doesn't indicate a simplified - arithmetic, rounding and precision/exponent adjustment is done only - once, namely, after multiplying and subtracting. - The result thisValue * multiplicand - - subtrahend. - The parameter or is null. - - - Gets an object with the same value as this one, but with - the sign reversed. - An arbitrary-precision decimal number. If this value is - positive zero, returns negative zero. Returns signaling NaN if this - value is signaling NaN. (In this sense, this method is similar to - the "copy-negate" operation in the General Decimal Arithmetic - Specification, except this method does not necessarily return a - copy of this object.). - - - Returns an arbitrary-precision decimal number with the - same value as this object but with the sign reversed. - An arithmetic context to control the - precision, rounding, and exponent range of the result. If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the precision is - unlimited and rounding isn't needed. - An arbitrary-precision decimal number. If this value is - positive zero, returns positive zero. Signals FlagInvalid and - returns quiet NaN if this value is signaling NaN. - - - Finds the largest value that's smaller than the given - value. - An arithmetic context object to control the - precision and exponent range of the result. The rounding mode from - this context is ignored. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). - Returns the largest value that's less than the given - value. Returns negative infinity if the result is negative - infinity. Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null, the precision is 0, or - has an unlimited exponent range. - - - Finds the smallest value that's greater than the given - value. - An arithmetic context object to control the - precision and exponent range of the result. The rounding mode from - this context is ignored. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). - Returns the smallest value that's greater than the given - value.Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null, the precision is 0, or - has an unlimited exponent range. - - - Finds the next value that is closer to the other object's - value than this object's value. Returns a copy of this value with - the same sign as the other value if both values are - equal. - An arbitrary-precision decimal number that - the return value will approach. - An arithmetic context object to control the - precision and exponent range of the result. The rounding mode from - this context is ignored. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). - Returns the next value that is closer to the other object' - s value than this object's value. Signals FlagInvalid and returns - NaN if the parameter is null, the precision - is 0, or has an unlimited exponent - range. - - - Rounds this object's value to a given precision, using the - given rounding mode and range of exponent, and also converts - negative zero to positive zero. The idiom - EDecimal.SignalingNaN.Plus(ctx) is useful for triggering an - invalid operation and returning not-a-number (NaN) for custom - arithmetic operations. - A context for controlling the precision, rounding - mode, and exponent range. Can be null, in which case the precision - is unlimited and rounding isn't needed. - The closest value to this object's value, rounded to the - specified precision. If is null or the - precision and exponent range are unlimited, returns the same value - as this object (or a quiet NaN if this object is a signaling - NaN). - - - Raises this object's value to the given - exponent. - An arbitrary-precision decimal number - expressing the exponent to raise this object's value to. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - This^exponent. Signals the flag FlagInvalid and returns - NaN if this object and exponent are both 0; or if this value is - less than 0 and the exponent either has a fractional part or is - infinity. Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null or the precision is - unlimited (the context's Precision property is 0), and the exponent - has a fractional part. - - - Raises this object's value to the given exponent, using - unlimited precision. - An arbitrary-precision decimal number - expressing the exponent to raise this object's value to. - This^exponent. Returns not-a-number (NaN) if the exponent - has a fractional part. - - - Raises this object's value to the given - exponent. - The exponent to raise this object's - value to. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - This^exponent. Signals the flag FlagInvalid and returns - NaN if this object and exponent are both 0. - - - Raises this object's value to the given - exponent. - The exponent to raise this object's - value to. - This^exponent. Returns not-a-number (NaN) if this object - and exponent are both 0. - - - Finds the number of digits in this number's significand. - Returns 1 if this value is 0, and 0 if this value is infinity or - not-a-number (NaN). - An arbitrary-precision integer. - - - - Returns an arbitrary-precision decimal number with the - same value but a new exponent. - Note that this is not always the same as rounding to a given - number of decimal places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - decimal places is desired, it's better to use the RoundToExponent - and RoundToIntegral methods instead. - Remark: - This method can be used to implement - fixed-point decimal arithmetic, in which each decimal number has a - fixed number of digits after the decimal point. The following code - example returns a fixed-point number with up to 20 digits before - and exactly 5 digits after the decimal point: - /* After performing arithmetic operations, adjust - /* the number to 5*/*/ - /**/ - digits after the decimal point number = number.Quantize( - EInteger.FromInt32(-5), /* five digits after the decimal - point*/ - EContext.ForPrecision(25) /* 25-digit - precision);*/ - A fixed-point decimal arithmetic in which no digits come - after the decimal point (a desired exponent of 0) is considered an - "integer arithmetic". - - The desired exponent for the result. - The exponent is the number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control precision and - rounding of the result. If HasFlags - of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - An arbitrary-precision decimal number with the same value - as this object but with the exponent changed. Signals FlagInvalid - and returns not-a-number (NaN) if this object is infinity, if the - rounded result can't fit the given precision, or if the context - defines an exponent range and the given exponent is outside that - range. - - - Returns an arbitrary-precision decimal number with the - same value as this one but a new exponent. - Remark: This method can be used to implement - fixed-point decimal arithmetic, in which a fixed number of digits - come after the decimal point. A fixed-point decimal arithmetic in - which no digits come after the decimal point (a desired exponent of - 0) is considered an "integer arithmetic" . - The desired exponent for the - result. The exponent is the number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - A rounding mode to use in case the result - needs to be rounded to fit the given exponent. - An arbitrary-precision decimal number with the same value - as this object but with the exponent changed. Returns not-a-number - (NaN) if this object is infinity, or if the rounding mode is - ERounding.None and the result is not exact. - - - - Returns an arbitrary-precision decimal number with the - same value but a new exponent. - Note that this is not always the same as rounding to a given - number of decimal places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - decimal places is desired, it's better to use the RoundToExponent - and RoundToIntegral methods instead. - Remark: - This method can be used to implement - fixed-point decimal arithmetic, in which each decimal number has a - fixed number of digits after the decimal point. The following code - example returns a fixed-point number with up to 20 digits before - and exactly 5 digits after the decimal point: - /* After performing arithmetic operations, adjust the number to 5 - digits - after the decimal point */ number = number.Quantize(-5, /* five digits - after the decimal point */EContext.ForPrecision(25) /* 25-digit - precision*/); - A fixed-point decimal arithmetic in which no digits come - after the decimal point (a desired exponent of 0) is considered an - "integer arithmetic". - - The desired exponent for the - result. The exponent is the number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control precision and - rounding of the result. If HasFlags - of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - An arbitrary-precision decimal number with the same value - as this object but with the exponent changed. Signals FlagInvalid - and returns not-a-number (NaN) if this object is infinity, if the - rounded result can't fit the given precision, or if the context - defines an exponent range and the given exponent is outside that - range. - - - Returns an arbitrary-precision decimal number with the - same value as this object but with the same exponent as another - decimal number. - Note that this is not always the same as rounding to a given - number of decimal places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - decimal places is desired, it's better to use the RoundToExponent - and RoundToIntegral methods instead. - Remark: This method can be used to implement - fixed-point decimal arithmetic, in which a fixed number of digits - come after the decimal point. A fixed-point decimal arithmetic in - which no digits come after the decimal point (a desired exponent of - 0) is considered an "integer arithmetic" . - An arbitrary-precision decimal number - containing the desired exponent of the result. The significand is - ignored. The exponent is the number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousands-place (10^3, 1000). A value of 0 rounds the number to - an integer. The following examples for this parameter express a - desired exponent of 3: 10e3, 8888e3, 4.56e5. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - An arbitrary-precision decimal number with the same value - as this object but with the exponent changed. Signals FlagInvalid - and returns not-a-number (NaN) if the result can't fit the given - precision without rounding, or if the arithmetic context defines an - exponent range and the given exponent is outside that - range. - - - Returns an object with the same numerical value as this - one but with trailing zeros removed from its significand. For - example, 1.00 becomes 1. - If this object's value is 0, changes the exponent to - 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - This value with trailing zeros removed. Note that if the - result has a very high exponent and the context says to clamp high - exponents, there may still be some trailing zeros in the - significand. - - - Returns the remainder that would result when this - arbitrary-precision decimal floating-point number is divided by - another arbitrary-precision decimal floating-point number. The - remainder is the number that remains when the absolute value of - this arbitrary-precision decimal floating-point number is divided - (as though by DivideToIntegerZeroScale) by the absolute value of - the other arbitrary-precision decimal floating-point number; the - remainder has the same sign (positive or negative) as this - arbitrary-precision decimal floating-point number. - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result, and of the - intermediate integer division. If HasFlags of the context is - true, will also store the flags resulting from the operation (the - flags are in addition to the pre-existing flags). Can be null, in - which the precision is unlimited. - The remainder that would result when this - arbitrary-precision decimal floating-point number is divided by - another arbitrary-precision decimal floating-point number. Signals - FlagDivideByZero and returns infinity if the divisor (this - arbitrary-precision decimal floating-point number) is 0 and the - dividend (the other arbitrary-precision decimal floating-point - number) is nonzero. Signals FlagInvalid and returns not-a-number - (NaN) if the divisor and the dividend are 0, or if the result of - the division doesn't fit the given precision. - - - Finds the remainder that results when dividing two - arbitrary-precision decimal numbers, except the intermediate - division is not adjusted to fit the precision of the given - arithmetic context. The value of this object is divided by the - absolute value of the other object; the remainder has the same sign - (positive or negative) as this object's value. - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result, but not also - of the intermediate integer division. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which the precision is unlimited. - The remainder of the two numbers. Signals FlagInvalid and - returns not-a-number (NaN) if the divisor is 0, or if the result - doesn't fit the given precision. - - - Calculates the remainder of a number by the formula - "this" - (("this" / "divisor") * "divisor"). - The number to divide by. - An arbitrary-precision decimal number. - - - Calculates the remainder of a number by the formula "this" - - (("this" / "divisor") * "divisor"). - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only in the division portion of the remainder - calculation; as a result, it's possible for the return value to - have a higher precision than given in this context. Flags will be - set on the given context only if the context's HasFlags is - true and the integer part of the division result doesn't fit the - precision and exponent range without rounding. Can be null, in - which the precision is unlimited and no additional rounding, other - than the rounding down to an integer after division, is - needed. - An arbitrary-precision decimal number. - - - Finds the distance to the closest multiple of the given - divisor, based on the result of dividing this object's value by - another object's value. - - If this and the other object divide evenly, the result is - 0. - If the remainder's absolute value is less than half of the - divisor's absolute value, the result has the same sign as this - object and will be the distance to the closest multiple. - If the remainder's absolute value is more than half of the - divisor's absolute value, the result has the opposite sign of this - object and will be the distance to the closest multiple. - If the remainder's absolute value is exactly half of the - divisor's absolute value, the result has the opposite sign of this - object if the quotient, rounded down, is odd, and has the same sign - as this object if the quotient, rounded down, is even, and the - result's absolute value is half of the divisor's absolute - value. This function is also known as the "IEEE - Remainder" function. - The number to divide by. - An arithmetic context object to control the - precision. The rounding and exponent range settings of this context - are ignored (the rounding mode is always treated as HalfEven). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which the precision is - unlimited. - The distance of the closest multiple. Signals FlagInvalid - and returns not-a-number (NaN) if the divisor is 0, or either the - result of integer division (the quotient) or the remainder wouldn't - fit the given precision. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to a new exponent if - necessary. The resulting number's Exponent property will not - necessarily be the given exponent; use the Quantize method instead - to give the result a particular exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - An arbitrary-precision decimal number rounded to the - closest value representable in the given precision. If the result - can't fit the precision, additional digits are discarded to make it - fit. Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to the given exponent when rounding, and the given - exponent is outside of the valid range of the arithmetic - context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to a new exponent if - necessary, using the HalfEven rounding mode. The resulting number's - Exponent property will not necessarily be the given exponent; use - the Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arbitrary-precision decimal number rounded to the - closest value representable for the given exponent. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to a new exponent if - necessary, using the given rounding mode. The resulting number's - Exponent property will not necessarily be the given exponent; use - the Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - Desired mode for rounding this number's - value. - An arbitrary-precision decimal number rounded to the - closest value representable for the given exponent. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to a new exponent if - necessary, using the HalfEven rounding mode. The resulting number's - Exponent property will not necessarily be the given exponent; use - the Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arbitrary-precision decimal number rounded to the - closest value representable for the given exponent. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to a new exponent if - necessary. The resulting number's Exponent property will not - necessarily be the given exponent; use the Quantize method instead - to give the result a particular exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - An arbitrary-precision decimal number rounded to the - closest value representable in the given precision. If the result - can't fit the precision, additional digits are discarded to make it - fit. Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to the given exponent when rounding, and the given - exponent is outside of the valid range of the arithmetic - context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to a new exponent if - necessary. The resulting number's Exponent property will not - necessarily be the given exponent; use the Quantize method instead - to give the result a particular exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - The desired mode to use to round the given - number to the given exponent. - An arbitrary-precision decimal number rounded to the given - negative number of decimal places. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to the given exponent - represented as an arbitrary-precision integer, and signals an - inexact flag if the result would be inexact. The resulting number's - Exponent property will not necessarily be the given exponent; use - the Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - An arbitrary-precision decimal number rounded to the - closest value representable in the given precision. Signals - FlagInvalid and returns not-a-number (NaN) if the result can't fit - the given precision without rounding. Signals FlagInvalid and - returns not-a-number (NaN) if the arithmetic context defines an - exponent range, the new exponent must be changed to the given - exponent when rounding, and the given exponent is outside of the - valid range of the arithmetic context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to the given exponent - represented as a 32-bit signed integer, and signals an inexact flag - if the result would be inexact. The resulting number's Exponent - property will not necessarily be the given exponent; use the - Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - An arbitrary-precision decimal number rounded to the - closest value representable in the given precision. Signals - FlagInvalid and returns not-a-number (NaN) if the result can't fit - the given precision without rounding. Signals FlagInvalid and - returns not-a-number (NaN) if the arithmetic context defines an - exponent range, the new exponent must be changed to the given - exponent when rounding, and the given exponent is outside of the - valid range of the arithmetic context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to the given exponent - represented as a 32-bit signed integer, and signals an inexact flag - if the result would be inexact. The resulting number's Exponent - property will not necessarily be the given exponent; use the - Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - Desired mode for rounding this object's - value. - An arbitrary-precision decimal number rounded to the - closest value representable using the given exponent. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to an integer, and signals an - inexact flag if the result would be inexact. The resulting number's - Exponent property will not necessarily be 0; use the Quantize - method instead to give the result an exponent of 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - An arbitrary-precision decimal number rounded to the - closest integer representable in the given precision. Signals - FlagInvalid and returns not-a-number (NaN) if the result can't fit - the given precision without rounding. Signals FlagInvalid and - returns not-a-number (NaN) if the arithmetic context defines an - exponent range, the new exponent must be changed to 0 when - rounding, and 0 is outside of the valid range of the arithmetic - context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to an integer, without adding - the FlagInexact or FlagRounded flags. The resulting - number's Exponent property will not necessarily be 0; use the - Quantize method instead to give the result an exponent of - 0. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags), except that this - function will never add the FlagRounded and - FlagInexact flags (the only difference between this and - RoundToExponentExact). Can be null, in which case the default - rounding mode is HalfEven. - An arbitrary-precision decimal number rounded to the - closest integer representable in the given precision. If the result - can't fit the precision, additional digits are discarded to make it - fit. Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to 0 when rounding, and 0 is outside of the valid range - of the arithmetic context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to an integer, and signals an - inexact flag if the result would be inexact. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - An arbitrary-precision decimal number rounded to the - closest integer representable in the given precision. Signals - FlagInvalid and returns not-a-number (NaN) if the result can't fit - the given precision without rounding. Signals FlagInvalid and - returns not-a-number (NaN) if the arithmetic context defines an - exponent range, the new exponent must be changed to 0 when - rounding, and 0 is outside of the valid range of the arithmetic - context. - - - Returns an arbitrary-precision decimal number with the - same value as this object but rounded to an integer, without adding - the FlagInexact or FlagRounded flags. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags), except that this - function will never add the FlagRounded and - FlagInexact flags (the only difference between this and - RoundToExponentExact). Can be null, in which case the default - rounding mode is HalfEven. - An arbitrary-precision decimal number rounded to the - closest integer representable in the given precision. If the result - can't fit the precision, additional digits are discarded to make it - fit. Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to 0 when rounding, and 0 is outside of the valid range - of the arithmetic context. - - - Rounds this object's value to a given precision, using the - given rounding mode and range of exponent. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The closest value to this object's value, rounded to the - specified precision. Returns the same value as this object if - is null or the precision and exponent range - are unlimited. - - - Returns a number in which the value of this object is - rounded to fit the maximum precision allowed if it has more - significant digits than the maximum precision. The maximum - precision allowed is given in an arithmetic context. This method is - designed for preparing operands to a custom arithmetic operation in - accordance with the "simplified" arithmetic given in Appendix A of - the General Decimal Arithmetic Specification. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Signals the - flag LostDigits if the input number has greater precision than - allowed and was rounded to a different numerical value in order to - fit the precision. - This object rounded to the given precision. Returns this - object and signals no flags if is null or - specifies an unlimited precision, if this object is infinity or - not-a-number (including signaling NaN), or if the number's value - has no more significant digits than the maximum precision given in - . - - - Returns a number similar to this number but with the scale - adjusted. - The power of 10 to scale by. - A number whose exponent is increased by . For example, if is 5, - "78E-2" becomes "78E+3" and has a bigger value. - - - Returns a number similar to this number but with the scale - adjusted. - The power of 10 to scale by. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - A number whose exponent is generally increased by - . For example, in general, if is 5, "78E-2" becomes "78E+3" and has a bigger - value. - - - Returns a number similar to this number but with the scale - adjusted. - The power of 10 to scale by. - A number whose exponent is increased by . For example, if - is 5, "78E-2" becomes "78E+3" and has a bigger value. - - - Returns a number similar to this number but with its scale - adjusted. - The power of 10 to scale by. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - A number whose exponent is generally increased by - . For example, in general, if - is 5, "78E-2" becomes "78E+3" and has - a bigger value. - The parameter is null. - - - Finds the square root of this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the square root function's - results are generally not exact for many inputs. (Unlike in the - General Decimal Arithmetic Specification, any rounding mode is - allowed.). - The square root. Signals the flag FlagInvalid and returns - NaN if this object is less than 0 (the square root would be a - complex number, but the return value is still NaN). Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Finds the square root of this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the square root function's - results are generally not exact for many inputs. (Unlike in the - General Decimal Arithmetic Specification, any rounding mode is - allowed.). - The square root. Signals the flag FlagInvalid and returns - NaN if this object is less than 0 (the square root would be a - complex number, but the return value is still NaN). Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Subtracts an arbitrary-precision decimal floating-point - number from this arbitrary-precision decimal floating-point number - and returns the result. The exponent for the result is the lower of - this arbitrary-precision decimal floating-point number's exponent - and the other arbitrary-precision decimal floating-point number's - exponent. - The number to subtract from this - instance's value. - The difference between the two numbers, that is, this - arbitrary-precision decimal floating-point number minus another - arbitrary-precision decimal floating-point number. If this - arbitrary-precision decimal floating-point number is not-a-number - (NaN), returns NaN. - - - Subtracts an arbitrary-precision decimal floating-point - number from this arbitrary-precision decimal floating-point number - and returns the result. - The number to subtract from this - instance's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The difference between the two numbers, that is, this - arbitrary-precision decimal floating-point number minus another - arbitrary-precision decimal floating-point number. If this - arbitrary-precision decimal floating-point number is not-a-number - (NaN), returns NaN. - The parameter is null. - - - Converts this value to its closest equivalent as a 64-bit - floating-point number encoded in the IEEE 754 binary64 format, - using the half-even rounding mode. - If this value is a NaN, sets the high bit of the binary64 - value's significand area for a quiet NaN, and clears it for a - signaling NaN. Then the other bits of the significand area are set - to the lowest bits of this object's unsigned significand, and the - next-highest bit of the significand area is set if those bits are - all zeros and this is a signaling NaN. - The closest 64-bit floating-point number to this value, - encoded in the IEEE 754 binary64 format. The return value can be - positive infinity or negative infinity, encoded in the IEEE 754 - binary64 format, if this value exceeds the range of a 64-bit - floating point number. - - - Converts this value to its closest equivalent as a 64-bit - floating-point number, using the half-even rounding mode. - If this value is a NaN, sets the high bit of the 64-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The closest 64-bit floating-point number to this value. - The return value can be positive infinity or negative infinity if - this value exceeds the range of a 64-bit floating point - number. - - - Converts this value to an arbitrary-precision integer, - discarding the fractional part in this value. Note that depending - on the value, especially the exponent, generating the - arbitrary-precision integer may require a huge amount of memory. - Use the ToSizedEInteger method to convert a number to an EInteger - only if the integer fits in a bounded bit range; that method will - throw an exception on overflow. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - There is not enough memory - to store the value as an EInteger. - - - Converts this value to an arbitrary-precision integer, - checking whether the fractional part of the value would be lost. - Note that depending on the value, especially the exponent, - generating the arbitrary-precision integer may require a huge - amount of memory. Use the ToSizedEIntegerIfExact method to convert - a number to an EInteger only if the integer fits in a bounded bit - range; that method will throw an exception on overflow. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - This object's value is not an - exact integer. - - - Converts this value to an arbitrary-precision integer, - checking whether the fractional part of the value would be lost. - Note that depending on the value, especially the exponent, - generating the arbitrary-precision integer may require a huge - amount of memory. Use the ToSizedEIntegerIfExact method to convert - a number to an EInteger only if the integer fits in a bounded bit - range; that method will throw an exception on overflow. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - This object's value is not an - exact integer. - - - Same as ToString(), except that when an exponent is used - it will be a multiple of 3. - A text string. - - - Creates a binary floating-point number from this object's - value. Note that if the binary floating-point number contains a - negative exponent, the resulting value might not be exact, in which - case the resulting binary floating-point number will be an - approximation of this decimal number's value, using the half-even - rounding mode. - An arbitrary-precision binary floating-point - number. - - - Creates a binary floating-point number from this object's - value. Note that if the binary floating-point number contains a - negative exponent, the resulting value might not be exact, in which - case the resulting binary floating-point number will be an - approximation of this decimal number's value, using the half-even - rounding mode. - An arbitrary-precision binary floating-point - number. - - - Converts this value to a string as though with the - ToString method, but without using exponential notation. - A text string. - - - Converts this value to its closest equivalent as a 32-bit - floating-point number encoded in the IEEE 754 binary32 format, - using the half-even rounding mode. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. - The closest 32-bit binary floating-point number to this - value, encoded in the IEEE 754 binary32 format. The return value - can be positive infinity or negative infinity if this value exceeds - the range of a 32-bit floating point number. - - - Converts this value to its closest equivalent as a 32-bit - floating-point number, using the half-even rounding mode. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The closest 32-bit binary floating-point number to this - value. The return value can be positive infinity or negative - infinity if this value exceeds the range of a 32-bit floating point - number. - - - Converts this value to a text string. Returns a value - compatible with this class's FromString method. - A string representation of this object. The text string - will be in exponential notation (expressed as a number 1 or - greater, but less than 10, times a power of 10) if this object's - Exponent property is greater than 0 or if the number's first - nonzero decimal digit is more than five digits after the decimal - point. - - - Returns the unit in the last place. The significand will - be 1 and the exponent will be this number's exponent. Returns 1 - with an exponent of 0 if this number is infinity or not-a-number - (NaN). - An arbitrary-precision decimal number. - - - Converts this value to an arbitrary-precision integer by - discarding its fractional part and checking whether the resulting - integer overflows the given signed bit count. - The maximum number of signed bits the - integer can have. The integer's value may not be less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN), or this number's value, once converted to an - integer by discarding its fractional part, is less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - - - Converts this value to an arbitrary-precision integer, - only if this number's value is an exact integer and that integer - does not overflow the given signed bit count. - The maximum number of signed bits the - integer can have. The integer's value may not be less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN), or this number's value, once converted to an - integer by discarding its fractional part, is less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - This object's value is not an - exact integer. - - - Creates a binary floating-point number from this object's - value. Note that if the binary floating-point number contains a - negative exponent, the resulting value might not be exact, in which - case the resulting binary floating-point number will be an - approximation of this decimal number's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. The precision is in - bits, and an example of this parameter is EContext.Binary64. Can be null. - An arbitrary-precision float floating-point - number. - - - This is an internal method. - A 32-bit signed integer. - - - This is an internal method. - An arbitrary-precision decimal number. - A 32-bit signed integer. - - - This is an internal method. - An arbitrary-precision decimal number. - An arbitrary-precision integer. - - - This is an internal method. - An arbitrary-precision decimal number. - An arbitrary-precision integer. - - - This is an internal method. - An arbitrary-precision decimal number. - A 32-bit signed integer. - - - This is an internal method. - The parameter is - a Numbers.EInteger object. - The parameter is - an internal parameter. - The parameter is an - internal parameter. - An arbitrary-precision decimal number. - - - This is an internal method. - A 32-bit signed integer. - - - This is an internal method. - The parameter is a 32-bit - signed integer. - An arbitrary-precision decimal number. - - - Returns one added to this arbitrary-precision decimal - number. - The given arbitrary-precision decimal number plus - one. - - - Returns one subtracted from this arbitrary-precision - decimal number. - The given arbitrary-precision decimal number minus - one. - - - 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. - This number's value, truncated to a byte (from 0 to - 255). - 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. - - - 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). - This number, converted to a byte (from 0 to 255). Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a byte (from 0 to 255). - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 255. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - decimal number. - The number to convert as a byte (from 0 to - 255). - This number's value as an arbitrary-precision decimal - number. - - - 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. - This number's value, truncated to a 16-bit signed - integer. - 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. - - - 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. - This number, converted to a 16-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -32768 or - greater than 32767. - - - Converts a 16-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 16-bit signed - integer. - This number's value as an arbitrary-precision decimal - number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -2147483648 - or greater than 2147483647. - - - 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. - This number's value, truncated to a 64-bit signed - integer. - 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. - - - 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. - This number, converted to a 64-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than - -9223372036854775808 or greater than - 9223372036854775807. - - - Converts this value to a decimal under the Common - Language Infrastructure (see - "Forms of numbers" ), - using the half-even rounding mode. - A decimal under the Common Language Infrastructure - (usually a.NET Framework decimal). - - - Converts a decimal under the Common Language - Infrastructure (see - "Forms of numbers" ) to - an arbitrary-precision decimal. - A decimal under the Common Language - Infrastructure (usually a.NET Framework decimal). - An arbitrary-precision decimal floating-point - number. - - - Converts a boolean value (true or false) to an arbitrary - precision decimal. - Either true or false. - The number 1 if is true; - otherwise, 0. - - - Converts an arbitrary-precision decimal number to a - decimal under the Common Language Infrastructure (see - "Forms of numbers" ), - using the half-even rounding mode. - The number to convert as an arbitrary-precision - decimal floating-point number. - A decimal under the Common Language Infrastructure - (usually a.NET Framework decimal). - - - Converts an arbitrary-precision decimal's value to a - decimal under the Common Language Infrastructure (see - "Forms of numbers" ), - using the half-even rounding mode. - The parameter is - an arbitrary-precision decimal floating-point number. - A decimal under the Common Language Infrastructure - (usually a.NET Framework decimal). - The parameter is null. - - - Converts an arbitrary-precision integer to an arbitrary - precision decimal. - An arbitrary-precision integer. - An arbitrary-precision decimal number with the exponent - set to 0. - - - Adds an arbitrary-precision decimal floating-point number - and another arbitrary-precision decimal floating-point number and - returns the result. - The first arbitrary-precision decimal - floating-point number. - The second decimal binary floating-point - number. - The sum of the two numbers, that is, an - arbitrary-precision decimal floating-point number plus another - arbitrary-precision decimal floating-point number. - The parameter or is - null. - - - Subtracts one arbitrary-precision decimal number from - another and returns the result. - The first operand. - The second operand. - The difference of the two decimal numbers. - The parameter or is - null. - - - Adds one to an arbitrary-precision decimal - number. - An arbitrary-precision decimal number. - The given arbitrary-precision decimal number plus - one. - The parameter is null. - - - Subtracts one from an arbitrary-precision decimal - number. - An arbitrary-precision decimal number. - The given arbitrary-precision decimal number minus - one. - The parameter is null. - - - Multiplies an arbitrary-precision decimal floating-point - number by another arbitrary-precision decimal floating-point number - and returns the result. - The first operand. - The second operand. - The product of the two numbers, that is, an - arbitrary-precision decimal floating-point number times another - arbitrary-precision decimal floating-point number. - The parameter or is - null. - - - Divides this object by another decimal number and returns - the result. When possible, the result will be exact. - The number that will be divided by the - divisor. - The number to divide by. - The quotient of the two numbers. Returns infinity if the - divisor is 0 and the dividend is nonzero. Returns not-a-number - (NaN) if the divisor and the dividend are 0. Returns NaN if the - result can't be exact because it would have a nonterminating - decimal expansion; examples include 1 divided by any multiple of 3, - such as 1/3 or 1/12. If this is not desired, use DivideToExponent - instead, or use the Divide overload that takes an EContext - instead. - The parameter is null. - - - Returns the remainder that would result when an - arbitrary-precision decimal floating-point number is divided by - another arbitrary-precision decimal floating-point number. The - remainder is the number that remains when the absolute value of an - arbitrary-precision decimal floating-point number is divided (as - though by DivideToIntegerZeroScale) by the absolute value of the - other arbitrary-precision decimal floating-point number; the - remainder has the same sign (positive or negative) as this - arbitrary-precision decimal floating-point number. - The number that will be divided by the - divisor. - The number to divide by. - The remainder that would result when an - arbitrary-precision decimal floating-point number is divided by - another arbitrary-precision decimal floating-point - number. - The parameter is null. - - - Gets an arbitrary-precision decimal number with the same - value as the given one, but with the sign reversed. - An arbitrary-precision decimal number to - negate. - An arbitrary-precision decimal number. If this value is - positive zero, returns negative zero. Returns signaling NaN if this - value is signaling NaN. - The parameter is null. - - - Converts an arbitrary-precision decimal floating-point - number to an arbitrary-precision integer. Any fractional part in - this value will be discarded when converting to an - arbitrary-precision integer. - The number to convert as an - arbitrary-precision decimal. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - The parameter is null. - - - Converts this value to its closest equivalent as a 64-bit - floating-point number. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 64-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The value to convert to a 64-bit - floating-point number. - The closest 64-bit floating-point number to this value. - The return value can be positive infinity or negative infinity if - this value exceeds the range of a 64-bit floating point - number. - The parameter is null. - - - Converts this value to its closest equivalent as a 32-bit - floating-point number. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The number to convert as an - arbitrary-precision decimal number. - The closest 32-bit binary floating-point number to this - value. The return value can be positive infinity or negative - infinity if this value exceeds the range of a 32-bit floating point - number. - The parameter is null. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - byte (from 0 to 255). - The parameter 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. - The parameter is null. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - decimal number. - The number to convert as a byte (from 0 to - 255). - The value of as an - arbitrary-precision decimal number. - - - 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. - This number's value, truncated to an 8-bit signed - integer. - 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. - - - 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. - This number, converted to an 8-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as an 8-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -128 or - greater than 127. - - - Converts an 8-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as an 8-bit signed - integer. - This number's value as an arbitrary-precision decimal - number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to an - 8-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts an 8-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as an 8-bit signed - integer. - The value of as an - arbitrary-precision decimal number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - 16-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 16-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 16-bit signed - integer. - The value of as an - arbitrary-precision decimal number. - - - 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. - This number's value, truncated to a 16-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 16-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 65535. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision decimal number. - The number to convert as a 16-bit - unsigned integer. - This number's value as an arbitrary-precision decimal - number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - 16-bit unsigned integer. - The parameter 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. - The parameter is null. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision decimal number. - The number to convert as a 16-bit - unsigned integer. - The value of as an - arbitrary-precision decimal number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - 32-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision decimal number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 4294967295. - - - Converts a 32-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 32-bit signed - integer. - This number's value as an arbitrary-precision decimal - number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - 32-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision decimal number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - 64-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 64-bit signed integer to an arbitrary-precision - decimal number. - The number to convert as a 64-bit signed - integer. - The value of as an - arbitrary-precision decimal number. - - - 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. - This number's value, truncated to a 64-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 64-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 18446744073709551615. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision decimal number. - The number to convert as a 64-bit - unsigned integer. - This number's value as an arbitrary-precision decimal - number. - - - Converts an arbitrary-precision decimal number 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. - The number to convert as an arbitrary-precision - decimal number. - The value of , truncated to a - 64-bit unsigned integer. - The parameter 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. - The parameter is null. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision decimal number. - The number to convert as a 64-bit - unsigned integer. - The value of as an - arbitrary-precision decimal number. - - - A class that implements additional operations on - arbitrary-precision decimal numbers. Many of them are listed as - miscellaneous operations in the General Decimal Arithmetic - Specification version 1.70. - - - Returns the number 10, the decimal radix. - Specifies an arithmetic context for rounding the - number 10. Can be null. - The number 10, or the closest representable number to 10 - in the arithmetic context. - - - Creates an arbitrary-precision decimal number from a - 32-bit signed integer. - The parameter is a 32-bit - signed integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - An arbitrary-precision decimal number with the closest - representable value to the given integer. - - - Converts a boolean value (either true or false) to an - arbitrary-precision decimal number. - Either true or false. - A context used for rounding the result. Can be - null. - Either 1 if is true, or 0 if - is false.. The result will be rounded as - specified by the given context, if any. - - - Returns whether the given arbitrary-precision number - object is in a canonical form. For the current version of EDecimal, - all EDecimal objects are in a canonical form. - An arbitrary-precision number object. - Always true. - - - Returns whether the given arbitrary-precision number - object is neither null nor infinity nor not-a-number - (NaN). - An arbitrary-precision number object. - Either true if the given arbitrary-precision number - object is neither null nor infinity nor not-a-number (NaN), or - false otherwise. - - - Returns whether the given arbitrary-precision number - object is positive or negative infinity. - An arbitrary-precision number object. - Either true if the given arbitrary-precision number - object is positive or negative infinity, or false - otherwise. - - - Returns whether the given arbitrary-precision number - object is a not-a-number (NaN). - An arbitrary-precision number object. - Either true or false. - - - Returns whether the given number is a - normal number. A - subnormal number is a nonzero finite number whose Exponent - property (or the number's exponent when that number is expressed in - scientific notation with one digit before the radix point) is less - than the minimum possible exponent for that number. A - normal number is nonzero and finite, but not - subnormal. - An arbitrary-precision number object. - A context specifying the exponent range of - arbitrary-precision numbers. Can be null. If AdjustExponent of the - given context is true, a nonzero number is normal if the - number's exponent (when that number is expressed in scientific - notation with one nonzero digit before the radix point) is at least - the given context's EMax property (e.g., if EMax is -100, 2.3456 * - 10 - -99 is normal, but 2.3456 * 10 - -102 is not). If AdjustExponent of the given context is - false, a nonzero number is subnormal if the number's - Exponent property is at least given context's EMax property (e.g., - if EMax is -100, 23456 * 10 - -99 is normal, but 23456 * 10 - -102 is not). - Either true if the given number is subnormal, or - false otherwise. Returns true if the given context is - null or HasExponentRange of the given context is false. - - - Returns whether the given arbitrary-precision number - object is a quiet not-a-number (NaN). - An arbitrary-precision number object. - Either true or false. - - - Returns whether the given arbitrary-precision number - object is negative (including negative infinity, negative - not-a-number [NaN], or negative zero). - An arbitrary-precision number object. - Either true or false. - - - Returns whether the given arbitrary-precision number - object is a signaling not-a-number (NaN). - An arbitrary-precision number object. - Either true or false. - - - Converts a number class identifier (ranging from 0 through - 9) to a text string. An arbitrary-precision number object can - belong in one of ten number classes. - An integer identifying a number class. - A text string identifying the given number class as - follows: 0 = "+Normal"; 1 = "-Normal", 2 = "+Subnormal", 3 = - "-Subnormal", 4 = "+Zero", 5 = "-Zero", 6 = "+Infinity", 7 = - "-Infinity", 8 = "NaN", 9 = "sNaN". - The parameter is less than 0 or greater than 9. - - - Finds the number class for an arbitrary-precision decimal - number object. - An arbitrary-precision decimal number - object. - A context object that specifies the precision and - exponent range of arbitrary-precision numbers. This is used only to - distinguish between normal and subnormal numbers. Can be - null. - A 32-bit signed integer identifying the given number - object, number class as follows: 0 = positive normal; 1 = negative - normal, 2 = positive subnormal, 3 = negative subnormal, 4 = - positive zero, 5 = negative zero, 6 = positive infinity, 7 = - negative infinity, 8 = quiet not-a-number (NaN), 9 = signaling - NaN. - The parameter is null. - - - Returns whether the given number is a - subnormal number. A - subnormal number is a nonzero finite number whose Exponent - property (or the number's exponent when that number is expressed in - scientific notation with one digit before the radix point) is less - than the minimum possible exponent for that number. - An arbitrary-precision number object. - A context specifying the exponent range of - arbitrary-precision numbers. Can be null. If AdjustExponent of the - given context is true, a nonzero number is subnormal if the - number's exponent (when that number is expressed in scientific - notation with one nonzero digit before the radix point) is less - than the given context's EMax property (e.g., if EMax is -100, - 2.3456 * 10 - -102 is subnormal, but 2.3456 * 10 - -99 is not). If AdjustExponent of the given context is - false, a nonzero number is subnormal if the number's - Exponent property is less than the given context's EMax property - (e.g., if EMax is -100, 23456 * 10 - -102 is subnormal, but 23456 * 10 - -99 is not). - Either true if the given number is subnormal, or - false otherwise. Returns false if the given context - is null or HasExponentRange of the given context is false. - The parameter is null. - - - Returns whether the given arbitrary-precision number - object is zero (positive zero or negative zero). - An arbitrary-precision number object. - true if the given number has a value of zero - (positive zero or negative zero); otherwise, false. - - - Returns the base-10 exponent of an arbitrary-precision - decimal number (when that number is expressed in scientific - notation with one digit before the radix point). For example, - returns 3 for the numbers 6.66E + 3 and 666E + 1. - An arbitrary-precision decimal number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - The base-10 exponent of the given number (when that number - is expressed in scientific notation with one nonzero digit before - the radix point). Signals DivideByZero and returns negative - infinity if is zero. Returns positive - infinity if is positive infinity or negative - infinity. - The parameter is null. - - - Finds an arbitrary-precision decimal number whose decimal - point is moved a given number of places. - An arbitrary-precision decimal number. - The number of decimal places to move the decimal - point of "ed". This must be an integer with an exponent of - 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - The given arbitrary-precision decimal number whose decimal - point is moved the given number of places. Signals an invalid - operation and returns not-a-number (NaN) if - is infinity or NaN, has an Exponent property other than 0. Signals - an invalid operation and returns not-a-number (NaN) if defines a limited precision and exponent range and if - 's absolute value is greater than twice the - sum of the context's EMax property and its Precision - property. - The parameter or is null. - - - Shifts the digits of an arbitrary-precision decimal - number's significand. - An arbitrary-precision number containing the - significand to shift. - An arbitrary-precision number indicating the - number of digits to shift the first operand's significand. Must be - an integer with an exponent of 0. If this parameter is positive, - the significand is shifted to the left by the given number of - digits. If this parameter is negative, the significand is shifted - to the right by the given number of digits. - An arithmetic context to control the precision of - arbitrary-precision numbers. Can be null. - An arbitrary-precision decimal number whose significand is - shifted the given number of digits. Signals an invalid operation - and returns NaN (not-a-number) if is a - signaling NaN or if is not an integer, is - negative, has an exponent other than 0, or has an absolute value - that exceeds the maximum precision specified in the - context. - The parameter or is null. - - - Rotates the digits of an arbitrary-precision decimal - number's significand. - An arbitrary-precision number containing the - significand to rotate. If this significand contains more digits - than the precision, the most-significant digits are chopped off the - significand before the rotation begins. - An arbitrary-precision number indicating the - number of digits to rotate the first operand's significand. Must be - an integer with an exponent of 0. If this parameter is positive, - the significand is shifted to the left by the given number of - digits and the most-significant digits shifted out of the - significand become the least-significant digits instead. If this - parameter is negative, the significand is shifted to the right by - the given number of digits and the least-significant digits shifted - out of the significand become the most-significant digits - instead. - An arithmetic context to control the precision of - arbitrary-precision numbers. If this parameter is null or specifies - an unlimited precision, this method has the same behavior as - Shift. - An arbitrary-precision decimal number whose significand is - rotated the given number of digits. Signals an invalid operation - and returns NaN (not-a-number) if is a - signaling NaN or if is not an integer, is - negative, has an exponent other than 0, or has an absolute value - that exceeds the maximum precision specified in the - context. - The parameter or is null. - - - Compares the values of one arbitrary-precision number - object and another object, imposing a total ordering on all - possible values. In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - The first arbitrary-precision number to - compare. - The second arbitrary-precision number to - compare. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects are null or equal, or -1 if - the first object is null or less than the other object, or 1 if the - first object is greater or the other object is null. Does not - signal flags if either value is signaling NaN. - - - Compares the absolute values of two arbitrary-precision - number objects, imposing a total ordering on all possible values - (ignoring their signs). In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero and positive zero are considered equal. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - The first arbitrary-precision number to - compare. - The second arbitrary-precision number to - compare. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects are null or equal (ignoring - their signs), or -1 if the first object is null or less than the - other value (ignoring their signs), or 1 if the first object is - greater (ignoring their signs) or the other object is null. Does - not signal flags if either value is signaling NaN. - - - Creates a copy of the given arbitrary-precision number - object. - An arbitrary-precision number object to - copy. - A copy of the given arbitrary-precision number - object. - The parameter is null. - - - Returns a canonical version of the given - arbitrary-precision number object. In this method, this method - behaves like the Copy method. - An arbitrary-precision number object. - A copy of the parameter . - - - Returns an arbitrary-precision number object with the same - value as the given number object but with a nonnegative sign (that - is, the given number object's absolute value). - An arbitrary-precision number object. - An arbitrary-precision number object with the same value - as the given number object but with a nonnegative sign. - The parameter is null. - - - Returns an arbitrary-precision number object with the sign - reversed from the given number object. - An arbitrary-precision number object. - An arbitrary-precision number object with the sign - reversed from the given number object. - The parameter is null. - - - Returns an arbitrary-precision number object with the same - value as the first given number object but with a the same sign - (positive or negative) as the second given number object. - An arbitrary-precision number object with the - value the result will have. - The parameter is an - arbitrary-precision decimal floating-point number. - An arbitrary-precision number object with the same value - as the first given number object but with a the same sign (positive - or negative) as the second given number object. - The parameter or is null. - - - Returns whether two arbitrary-precision numbers have the - same exponent, they both are not-a-number (NaN), or they both are - infinity (positive and/or negative). - The first arbitrary-precision number. - The second arbitrary-precision number. - Either true if the given arbitrary-precision - numbers have the same exponent, they both are not-a-number (NaN), - or they both are infinity (positive and/or negative); otherwise, - false. - - - Returns an arbitrary-precision number with the same value - as this one but with certain trailing zeros removed from its - significand. If the number's exponent is 0, it is returned - unchanged (but may be rounded depending on the arithmetic context); - if that exponent is greater 0, its trailing zeros are removed from - the significand (then rounded if necessary); if that exponent is - less than 0, its trailing zeros are removed from the significand - until the exponent reaches 0 (then the number is rounded if - necessary). - An arbitrary-precision number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - An arbitrary-precision number with the same value as this - one but with certain trailing zeros removed from its significand. - If is not-a-number (NaN) or infinity, it is - generally returned unchanged. - - - Returns an arbitrary-precision decimal number with the - same value as this object but with the given exponent, expressed as - an arbitrary-precision decimal number. - Note that this is not always the same as rounding to a given - number of decimal places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - decimal places is desired, it's better to use the RoundToExponent - and RoundToIntegral methods instead. - Remark: This method can be used to implement - fixed-point decimal arithmetic, in which a fixed number of digits - come after the decimal point. A fixed-point decimal arithmetic in - which no digits come after the decimal point (a desired exponent of - 0) is considered an "integer arithmetic" . - An arbitrary-precision decimal number whose - exponent is to be changed. - The desired exponent of the result, expressed - as an arbitrary-precision decimal number. The exponent is the - number of fractional digits in the result, expressed as a negative - number. Can also be positive, which eliminates lower-order places - from the number. For example, -3 means round to the thousandth - (10^-3, 0.0001), and 3 means round to the thousands-place (10^3, - 1000). A value of 0 rounds the number to an integer. - The parameter is an EContext - object. - An arbitrary-precision decimal number with the same value - as this object but with the exponent changed. Signals FlagInvalid - and returns not-a-number (NaN) if the result can't fit the given - precision without rounding, or if the arithmetic context defines an - exponent range and the given exponent is outside that - range. - - - Performs a logical AND operation on two decimal numbers in - the form of - logical operands. A logical operand is a - non-negative base-10 number with an Exponent property of 0 and no - other base-10 digits than 0 or 1 (examples include 01001 and - 111001, but not 02001 or 99999 ). The logical - AND operation sets each digit of the result to 1 if the - corresponding digits of each logical operand are both 1, and to 0 - otherwise. For example, 01001 AND 111010=01000. - The first logical operand to the logical AND - operation. - The second logical operand to the logical AND - operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more digits than the maximum precision - specified in this context, the operand's most significant digits - that exceed that precision are discarded. This parameter can be - null. - The result of the logical AND operation as a logical - operand. Signals an invalid operation and returns not-a-number - (NaN) if , , or both - are not logical operands. - - - Performs a logical NOT operation on an arbitrary-precision - decimal number in the form of a - logical operand. A logical operand is a non-negative - base-10 number with an Exponent property of 0 and no other base-10 - digits than 0 or 1 (examples include 01001 and 111001 - , but not 02001 or 99999 ). The logical NOT operation - sets each digit of the result to 1 if the corresponding digit is 0, - and to 0 otherwise; it can set no more digits than the maximum - precision, however. For example, if the maximum precision is 8 - digits, then NOT 111010=11000101. - The logical operand to the logical NOT - operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more digits than the maximum precision - specified in this context, the operand's most significant digits - that exceed that precision are discarded. This parameter cannot be - null and must specify a maximum precision (unlimited precision - contexts are not allowed). - The result of the logical NOT operation as a logical - operand. Signals an invalid operation and returns not-a-number - (NaN) if is not a logical operand. - - - Performs a logical exclusive-OR (XOR) operation on two - decimal numbers in the form of - logical operands. A logical operand is a - non-negative base-10 number with an exponent of 0 and no other - base-10 digits than 0 or 1 (examples include 01001 and - 111001, but not 02001 or 99999 ). The logical - exclusive-OR operation sets each digit of the result to 1 if either - corresponding digit of the logical operands, but not both, is 1, - and to 0 otherwise. For example, 01001 XOR 111010=101010. - The first logical operand to the logical - exclusive-OR operation. - The second logical operand to the logical - exclusive-OR operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more digits than the maximum precision - specified in this context, the operand's most significant digits - that exceed that precision are discarded. This parameter can be - null. - An arbitrary-precision decimal floating-point - number. - - - Performs a logical OR operation on two decimal numbers in - the form of - logical operands. A logical operand is a - non-negative base-10 number with an Exponent property of 0 and no - other base-10 digits than 0 or 1 (examples include 01001 and - 111001, but not 02001 or 99999 ). The logical - OR operation sets each digit of the result to 1 if either or both - of the corresponding digits of the logical operands are 1, and to 0 - otherwise. For example, 01001 OR 111010=111011. - The first logical operand to the logical OR - operation. - The second logical operand to the logical OR - operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more digits than the maximum precision - specified in this context, the operand's most significant digits - that exceed that precision are discarded. This parameter can be - null. - The result of the logical OR operation as a logical - operand. Signals an invalid operation and returns not-a-number - (NaN) if , , or both - are not logical operands. - - - Represents an arbitrary-precision binary floating-point - number. (The "E" stands for "extended", meaning that instances of - this class can be values other than numbers proper, such as - infinity and not-a-number.) Each number consists of an integer - significand and an integer exponent, both arbitrary-precision. The - value of the number equals significand * 2^exponent. This class - also supports values for negative zero, not-a-number (NaN) values, - and infinity. - Passing a signaling NaN to any arithmetic operation shown - here will signal the flag FlagInvalid and return a quiet NaN, even - if another operand to that operation is a quiet NaN, unless the - operation's documentation expressly states that another result - happens when a signaling NaN is passed to that operation. - Passing a quiet NaN to any arithmetic operation shown here - will return a quiet NaN, unless the operation's documentation - expressly states that another result happens when a quiet NaN is - passed to that operation. - Unless noted otherwise, passing a null arbitrary-precision - binary floating-point number argument to any method here will throw - an exception. - When an arithmetic operation signals the flag FlagInvalid, - FlagOverflow, or FlagDivideByZero, it will not throw an exception - too, unless the operation's trap is enabled in the arithmetic - context (see EContext's Traps property). - An arbitrary-precision binary floating-point number value can - be serialized in one of the following ways: - - By calling the toString() method. However, not all strings - can be converted back to an arbitrary-precision binary - floating-point number without loss, especially if the string has a - fractional part. - By calling the UnsignedMantissa, Exponent, and IsNegative - properties, and calling the IsInfinity, IsQuietNaN, and - IsSignalingNaN methods. The return values combined will uniquely - identify a particular arbitrary-precision binary floating-point - number value. - If an operation requires creating an intermediate value that - might be too big to fit in memory (or might require more than 2 - gigabytes of memory to store -- due to the current use of a 32-bit - integer internally as a length), the operation may signal an - invalid-operation flag and return not-a-number (NaN). In certain - rare cases, the CompareTo method may throw OutOfMemoryException - (called OutOfMemoryError in Java) in the same circumstances. - Thread safety - Instances of this class are immutable, so they are inherently - safe for use by multiple threads. Multiple instances of this object - with the same properties are interchangeable, so they should not be - compared using the "==" operator (which might only check if each - side of the operator is the same instance). - Comparison considerations - This class's natural ordering (under the CompareTo method) is - not consistent with the Equals method. This means that two values - that compare as equal under the CompareTo method might not be equal - under the Equals method. The CompareTo method compares the - mathematical values of the two instances passed to it (and - considers two different NaN values as equal), while two instances - with the same mathematical value, but different exponents, will be - considered unequal under the Equals method. - Security note - It is not recommended to implement security-sensitive - algorithms using the methods in this class, for several - reasons: - - EFloat objects are immutable, so they can't be - modified, and the memory they occupy is not guaranteed to be - cleared in a timely fashion due to garbage collection. This is - relevant for applications that use many-bit-long numbers as secret - parameters. - The methods in this class (especially those that involve - arithmetic) are not guaranteed to be "constant-time" - (non-data-dependent) for all relevant inputs. Certain attacks that - involve encrypted communications have exploited the timing and - other aspects of such communications to derive keying material or - cleartext indirectly. - Applications should instead use dedicated security libraries - to handle big numbers in security-sensitive algorithms. - Reproducibility note - See the reproducibility note in the EDecimal class's - documentation. - - - A not-a-number value. - - - Negative infinity, less than any other number. - - - Represents the number negative zero. - - - Represents the number 1. - - - Positive infinity, greater than any other - number. - - - A not-a-number value that signals an invalid operation - flag when it's passed as an argument to any arithmetic operation in - arbitrary-precision binary floating-point number. - - - Represents the number 10. - - - Represents the number 0. - - - Gets this object's exponent. This object's value will be - an integer if the exponent is positive or zero. - This object's exponent. This object's value will be an - integer if the exponent is positive or zero. - - - Gets a value indicating whether this object is finite (not - infinity or not-a-number, NaN). - true if this object is finite (not infinity or - not-a-number, NaN); otherwise, false. - - - Gets a value indicating whether this object is negative, - including negative zero. - true if this object is negative, including negative - zero; otherwise, false. - - - Gets a value indicating whether this object's value equals - 0. - true if this object's value equals 0; otherwise, - false. true if this object's value equals 0; - otherwise, false. - - - Gets this object's unscaled value, or significand, and - makes it negative if this object is negative. If this value is - not-a-number (NaN), that value's absolute value is the NaN's - "payload" (diagnostic information). - This object's unscaled value. Will be negative if this - object's value is negative (including a negative NaN). - - - Gets this value's sign: -1 if negative; 1 if positive; 0 - if zero. - This value's sign: -1 if negative; 1 if positive; 0 if - zero. - - - Gets the absolute value of this object's unscaled value, - or significand. If this value is not-a-number (NaN), that value is - the NaN's "payload" (diagnostic information). - The absolute value of this object's unscaled value. - - - Creates a copy of this arbitrary-precision binary - number. - An arbitrary-precision binary floating-point - number. - - - Returns an arbitrary-precision number with the value - exponent*2^significand. - Desired value for the - significand. - Desired value for the exponent. - An arbitrary-precision binary number. - - - Returns an arbitrary-precision number with the value - exponent*2^significand. - Desired value for the significand. - Desired value for the exponent. - An arbitrary-precision binary number. - The parameter is null. - - - Returns an arbitrary-precision number with the value - exponent*2^significand. - Desired value for the significand. - Desired value for the exponent. - An arbitrary-precision binary number. - The parameter is null. - - - Returns an arbitrary-precision number with the value - exponent*2^significand. - Desired value for the significand. - Desired value for the exponent. - An arbitrary-precision binary number. - The parameter or is - null. - - - Returns an arbitrary-precision number with the value - exponent*2^significand. - Desired value for the - significand. - Desired value for the exponent. - An arbitrary-precision binary number. - - - Returns an arbitrary-precision number with the value - exponent*2^significand. - Desired value for the - significand. - Desired value for the exponent. - An arbitrary-precision binary number. - - - Creates a not-a-number arbitrary-precision binary - number. - An integer, 0 or greater, to use as diagnostic - information associated with this object. If none is needed, should - be zero. To get the diagnostic information from another - arbitrary-precision binary floating-point number, use that object's - UnsignedMantissa property. - A quiet not-a-number. - - - Creates a not-a-number arbitrary-precision binary - number. - An integer, 0 or greater, to use as diagnostic - information associated with this object. If none is needed, should - be zero. To get the diagnostic information from another - arbitrary-precision binary floating-point number, use that object's - UnsignedMantissa property. - Whether the return value will be signaling - (true) or quiet (false). - Whether the return value is - negative. - An arithmetic context to control the precision - (in binary digits) of the diagnostic information. The rounding and - exponent range of this context will be ignored. Can be null. The - only flag that can be signaled in this context is FlagInvalid, - which happens if diagnostic information needs to be truncated and - too much memory is required to do so. - An arbitrary-precision binary number. - The parameter is null or is less than 0. - - - Creates a binary floating-point number from a 64-bit - floating-point number encoded in the IEEE 754 binary64 format. This - method computes the exact value of the floating point number, not - an approximation, as is often the case by converting the floating - point number to a string first. - The parameter is a - 64-bit signed integer. - A binary floating-point number with the same value as the - floating-point number encoded in . - - - Creates a binary floating-point number from a 32-bit - floating-point number. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the floating point number to a string - first. - The parameter is a 64-bit - floating-point number. - A binary floating-point number with the same value as - . - - - Creates a binary floating-point number from a 64-bit - floating-point number. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the floating point number to a string - first. - The parameter is a 64-bit - floating-point number. - A binary floating-point number with the same value as - . - - - Converts an arbitrary-precision integer to the same value - as a binary floating-point number. - An arbitrary-precision integer. - An arbitrary-precision binary floating-point - number. - - - Creates a binary floating-point number from a 32-bit - floating-point number encoded in the IEEE 754 binary32 format. This - method computes the exact value of the floating point number, not - an approximation, as is often the case by converting the floating - point number to a string first. - A 32-bit binary floating-point number encoded - in the IEEE 754 binary32 format. - A binary floating-point number with the same - floating-point value as . - - - Creates a binary floating-point number from a text string - that represents a number. Note that if the string contains a - negative exponent, the resulting value might not be exact, in which - case the resulting binary floating-point number will be an - approximation of this decimal number's value. - The format of the string generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if '-' , the value is negative.) - One or more digits, with a single optional decimal point - (".", U+002E) before or after those digits or between two of them. - These digits may begin with any number of zeros. - Optionally, "E+"/"e+" (positive exponent) or "E-"/"e-" - (negative exponent) plus one or more digits specifying the exponent - (these digits may begin with any number of zeros). - The string can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN") followed by any number of digits (these - digits may begin with any number of zeros), or signaling NaN - ("sNaN") followed by any number of digits (these digits may begin - with any number of zeros), all where the letters can be any - combination of basic upper-case and/or basic lower-case - letters. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The string is not - allowed to contain white space characters, including - spaces. - The parameter is a text - string. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Note that - providing a context is often much faster than creating an EDecimal - without a context then calling ToEFloat on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - The portion given of is not a correctly formatted number string; or either - or is less than - 0 or greater than 's length, or 's length minus is less than - . - - - Creates a binary floating-point number from a text string - that represents a number, using an unlimited precision context. For - more information, see the FromString(String, int, int, - EContext) method. - A text string to convert to a binary - floating-point number. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - The portion given of is not a correctly formatted number - string. - - - Creates a binary floating-point number from a text string - that represents a number. For more information, see the - FromString(String, int, int, EContext) method. - A text string to convert to a binary - floating-point number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Note that - providing a context is often much faster than creating an EDecimal - without a context then calling ToEFloat on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - - - Creates a binary floating-point number from a text string - that represents a number. For more information, see the - FromString(String, int, int, EContext) method. - The parameter is a text - string. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision binary floating-point - number. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - Creates a binary floating-point number from a sequence of - char s that represents a number. Note that if the sequence - contains a negative exponent, the resulting value might not be - exact, in which case the resulting binary floating-point number - will be an approximation of this decimal number's value. - The format of the sequence generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if '-' , the value is negative.) - One or more digits, with a single optional decimal point - (".", U+002E) before or after those digits or between two of them. - These digits may begin with any number of zeros. - Optionally, "E+"/"e+" (positive exponent) or "E-"/"e-" - (negative exponent) plus one or more digits specifying the exponent - (these digits may begin with any number of zeros). - The sequence can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN") followed by any number of digits (these - digits may begin with any number of zeros), or signaling NaN - ("sNaN") followed by any number of digits (these digits may begin - with any number of zeros), all where the letters can be any - combination of basic upper-case and/or basic lower-case - letters. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The sequence is not - allowed to contain white space characters, including - spaces. - A sequence of char s to convert to a - binary floating-point number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Note that - providing a context is often much faster than creating an EDecimal - without a context then calling ToEFloat on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - The portion given of is not a correctly formatted number sequence; or - either or is - less than 0 or greater than 's length, or - 's length minus - is less than . - - - Creates a binary floating-point number from a sequence of - char s that represents a number, using an unlimited - precision context. For more information, see the - FromString(String, int, int, EContext) method. - A sequence of char s to convert to a - binary floating-point number. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - The portion given of is not a correctly formatted number - sequence. - - - Creates a binary floating-point number from a sequence of - char s that represents a number. For more information, see - the FromString(String, int, int, EContext) method. - A sequence of char s to convert to a - binary floating-point number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Note that - providing a context is often much faster than creating an EDecimal - without a context then calling ToEFloat on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - - - Creates a binary floating-point number from a sequence of - char s that represents a number. For more information, see - the FromString(String, int, int, EContext) method. - A sequence of char s to convert to a - binary floating-point number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision binary floating-point - number. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Creates a binary floating-point number from a sequence of - bytes that represents a number. Note that if the sequence contains - a negative exponent, the resulting value might not be exact, in - which case the resulting binary floating-point number will be an - approximation of this decimal number's value. - The format of the sequence generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if '-' , the value is negative.) - One or more digits, with a single optional decimal point - (".", U+002E) before or after those digits or between two of them. - These digits may begin with any number of zeros. - Optionally, "E+"/"e+" (positive exponent) or "E-"/"e-" - (negative exponent) plus one or more digits specifying the exponent - (these digits may begin with any number of zeros). - The sequence can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN") followed by any number of digits (these - digits may begin with any number of zeros), or signaling NaN - ("sNaN") followed by any number of digits (these digits may begin - with any number of zeros), all where the letters can be any - combination of basic upper-case and/or basic lower-case - letters. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The sequence is not - allowed to contain white space characters, including - spaces. - A sequence of bytes to convert to a binary - floating-point number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Note that - providing a context is often much faster than creating an EDecimal - without a context then calling ToEFloat on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - The portion given of is not a correctly formatted number sequence; or - either or is - less than 0 or greater than 's length, or - 's length minus - is less than . - - - Creates a binary floating-point number from a sequence of - bytes that represents a number, using an unlimited precision - context. For more information, see the FromString(String, int, - int, EContext) method. - A sequence of bytes to convert to a binary - floating-point number. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - The portion given of is not a correctly formatted number - sequence. - - - Creates a binary floating-point number from a sequence of - bytes that represents a number. For more information, see the - FromString(String, int, int, EContext) method. - A sequence of bytes to convert to a binary - floating-point number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of the - context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Note that - providing a context is often much faster than creating an EDecimal - without a context then calling ToEFloat on that EDecimal, - especially if the context specifies a precision limit and exponent - range. - The parsed number, converted to arbitrary-precision binary - floating-point number. - The parameter is null. - - - Creates a binary floating-point number from a sequence of - bytes that represents a number. For more information, see the - FromString(String, int, int, EContext) method. - A sequence of bytes to convert to a binary - floating-point number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision binary floating-point - number. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Gets the greater value between two binary floating-point - numbers. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The larger value of the two numbers. If one is positive - zero and the other is negative zero, returns the positive zero. If - the two numbers are positive and have the same value, returns the - one with the larger exponent. If the two numbers are negative and - have the same value, returns the one with the smaller - exponent. - The parameter or is null. - - - Gets the greater value between two binary floating-point - numbers. - The first value to compare. - The second value to compare. - The larger value of the two numbers. If one is positive - zero and the other is negative zero, returns the positive zero. If - the two numbers are positive and have the same value, returns the - one with the larger exponent. If the two numbers are negative and - have the same value, returns the one with the smaller - exponent. - The parameter or is null. - - - Gets the greater value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Max. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The larger value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the greater value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Max. - The first value to compare. - The second value to compare. - The larger value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the lesser value between two binary floating-point - numbers. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The smaller value of the two numbers. If one is positive - zero and the other is negative zero, returns the negative zero. If - the two numbers are positive and have the same value, returns the - one with the smaller exponent. If the two numbers are negative and - have the same value, returns the one with the larger - exponent. - The parameter or is null. - - - Gets the lesser value between two binary floating-point - numbers. - The first value to compare. - The second value to compare. - The smaller value of the two numbers. If one is positive - zero and the other is negative zero, returns the negative zero. If - the two numbers are positive and have the same value, returns the - one with the smaller exponent. If the two numbers are negative and - have the same value, returns the one with the larger - exponent. - The parameter or is null. - - - Gets the lesser value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Min. - The first value to compare. - The second value to compare. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The smaller value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the lesser value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Min. - The first value to compare. - The second value to compare. - The smaller value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Finds the constant π, the circumference of a circle - divided by its diameter. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as π can never be represented - exactly.. - The constant π rounded to the given precision. Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Finds the absolute value of this object (if it's negative, - it becomes positive). - An arbitrary-precision binary floating-point number. - Returns signaling NaN if this value is signaling NaN. (In this - sense, this method is similar to the "copy-abs" operation in the - General Decimal Arithmetic Specification, except this method does - not necessarily return a copy of this object.). - - - Finds the absolute value of this object (if it's negative, - it becomes positive). - An arithmetic context to control the - precision, rounding, and exponent range of the result. If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the precision is - unlimited and no rounding is needed. - The absolute value of this object. Signals FlagInvalid and - returns quiet NaN if this value is signaling NaN. - - - Adds this arbitrary-precision binary floating-point number - and a 32-bit signed integer and returns the result. The exponent - for the result is the lower of this arbitrary-precision binary - floating-point number's exponent and the other 32-bit signed - integer's exponent. - The parameter is - a 32-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision binary floating-point number plus a 32-bit - signed integer. If this arbitrary-precision binary floating-point - number is not-a-number (NaN), returns NaN. - - - Subtracts a 32-bit signed integer from this - arbitrary-precision binary floating-point number and returns the - result. The exponent for the result is the lower of this - arbitrary-precision binary floating-point number's exponent and the - other 32-bit signed integer's exponent. - The parameter is - a 32-bit signed integer. - The difference between the two numbers, that is, this - arbitrary-precision binary floating-point number minus a 32-bit - signed integer. If this arbitrary-precision binary floating-point - number is not-a-number (NaN), returns NaN. - - - Multiplies this arbitrary-precision binary floating-point - number by a 32-bit signed integer and returns the result. The - exponent for the result is this arbitrary-precision binary - floating-point number's exponent plus the other 32-bit signed - integer's exponent. - The parameter is - a 32-bit signed integer. - The product of the two numbers, that is, this - arbitrary-precision binary floating-point number times a 32-bit - signed integer. - - EInteger result = EInteger.FromString("5").Multiply(200); - . - - - - Divides this arbitrary-precision binary floating-point - number by a 32-bit signed integer and returns the result; returns - NaN instead if the result would have a nonterminating binary - expansion (including 1/3, 1/12, 1/7, 2/3, and so on); if this is - not desired, use DivideToExponent, or use the Divide overload that - takes an EContext. - The divisor. - The result of dividing this arbitrary-precision binary - floating-point number by a 32-bit signed integer. Returns infinity - if the divisor (this arbitrary-precision binary floating-point - number) is 0 and the dividend (the other 32-bit signed integer) is - nonzero. Returns not-a-number (NaN) if the divisor and the dividend - are 0. Returns NaN if the result can't be exact because it would - have a nonterminating binary expansion (examples include 1 divided - by any multiple of 3, such as 1/3 or 1/12). If this is not desired, - use DivideToExponent instead, or use the Divide overload that takes - an EContext (such as EContext.Binary64 ) - instead. - Attempted to divide by - zero. - - - Adds this arbitrary-precision binary floating-point number - and a 64-bit signed integer and returns the result. The exponent - for the result is the lower of this arbitrary-precision binary - floating-point number's exponent and the other 64-bit signed - integer's exponent. - The parameter - is a 64-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision binary floating-point number plus a 64-bit - signed integer. If this arbitrary-precision binary floating-point - number is not-a-number (NaN), returns NaN. - - - Subtracts a 64-bit signed integer from this - arbitrary-precision binary floating-point number and returns the - result. The exponent for the result is the lower of this - arbitrary-precision binary floating-point number's exponent and the - other 64-bit signed integer's exponent. - The parameter - is a 64-bit signed integer. - The difference between the two numbers, that is, this - arbitrary-precision binary floating-point number minus a 64-bit - signed integer. If this arbitrary-precision binary floating-point - number is not-a-number (NaN), returns NaN. - - - Multiplies this arbitrary-precision binary floating-point - number by a 64-bit signed integer and returns the result. The - exponent for the result is this arbitrary-precision binary - floating-point number's exponent plus the other 64-bit signed - integer's exponent. - The parameter - is a 64-bit signed integer. - The product of the two numbers, that is, this - arbitrary-precision binary floating-point number times a 64-bit - signed integer. - - EInteger result = EInteger.FromString("5").Multiply(200L); - . - - - - Divides this arbitrary-precision binary floating-point - number by a 64-bit signed integer and returns the result; returns - NaN instead if the result would have a nonterminating binary - expansion (including 1/3, 1/12, 1/7, 2/3, and so on); if this is - not desired, use DivideToExponent, or use the Divide overload that - takes an EContext. - The parameter - is a 64-bit signed integer. - The result of dividing this arbitrary-precision binary - floating-point number by a 64-bit signed integer. Returns infinity - if the divisor (this arbitrary-precision binary floating-point - number) is 0 and the dividend (the other 64-bit signed integer) is - nonzero. Returns not-a-number (NaN) if the divisor and the dividend - are 0. Returns NaN if the result can't be exact because it would - have a nonterminating binary expansion (examples include 1 divided - by any multiple of 3, such as 1/3 or 1/12). If this is not desired, - use DivideToExponent instead, or use the Divide overload that takes - an EContext (such as EContext.Binary64 ) - instead. - Attempted to divide by - zero. - - - Adds this arbitrary-precision binary floating-point number - and another arbitrary-precision binary floating-point number and - returns the result. The exponent for the result is the lower of - this arbitrary-precision binary floating-point number's exponent - and the other arbitrary-precision binary floating-point number's - exponent. - An arbitrary-precision binary - floating-point number. - The sum of the two numbers, that is, this - arbitrary-precision binary floating-point number plus another - arbitrary-precision binary floating-point number. If this - arbitrary-precision binary floating-point number is not-a-number - (NaN), returns NaN. - - - Adds this arbitrary-precision binary floating-point number - and another arbitrary-precision binary floating-point number and - returns the result. - The number to add to. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The sum of the two numbers, that is, this - arbitrary-precision binary floating-point number plus another - arbitrary-precision binary floating-point number. If this - arbitrary-precision binary floating-point number is not-a-number - (NaN), returns NaN. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - An arbitrary-precision binary floating-point - number. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value or if is null, or 0 if both - values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object or the other object is a quiet NaN or - signaling NaN, this method will not trigger an error. Instead, NaN - will compare greater than any other number, including infinity. Two - different NaN values will be considered equal. - An arbitrary-precision binary floating-point - number. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value or if is null, or 0 if both - values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - The parameter is - a 32-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object is a quiet NaN or signaling NaN, this method - will not trigger an error. Instead, NaN will compare greater than - any other number. - The parameter is - a 32-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object is a quiet NaN or signaling NaN, this method - will not trigger an error. Instead, NaN will compare greater than - any other number, including infinity. - The parameter is - a 64-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - The parameter is - a 64-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, treating quiet NaN as signaling. - In this method, negative zero and positive zero are - considered equal. - If this object or the other object is a quiet NaN or - signaling NaN, this method will return a quiet NaN and will signal - a FlagInvalid flag. - An arbitrary-precision binary floating-point - number. - An arithmetic context. The precision, rounding, - and exponent range are ignored. If HasFlags of the context - is true, will store the flags resulting from the operation (the - flags are in addition to the pre-existing flags). Can be - null. - Quiet NaN if this object or the other object is NaN, or 0 - if both objects have the same value, or -1 if this object is less - than the other value, or 1 if this object is greater. - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values. In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision binary floating-point - number to compare with this one. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. Does not signal flags if either value is signaling NaN. - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values (ignoring their - signs). In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision binary floating-point - number to compare with this one. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects have the same value (ignoring - their signs), or -1 if this object is less than the other value - (ignoring their signs), or 1 if this object is greater (ignoring - their signs). Does not signal flags if either value is signaling - NaN. - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values. In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision binary floating-point - number to compare with this one. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. - This implementation returns a positive number if 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.. - - - Compares the absolute values of this object and another - object, imposing a total ordering on all possible values (ignoring - their signs). In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero and positive zero are considered equal. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - An arbitrary-precision binary floating-point - number to compare with this one. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. - This implementation returns a positive number if 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.. - - - Compares the mathematical values of this object and - another object. - In this method, negative zero and positive zero are - considered equal. - If this object or the other object is a quiet NaN or - signaling NaN, this method returns a quiet NaN, and will signal a - FlagInvalid flag if either is a signaling NaN. - An arbitrary-precision binary floating-point - number. - An arithmetic context. The precision, rounding, - and exponent range are ignored. If HasFlags of the context - is true, will store the flags resulting from the operation (the - flags are in addition to the pre-existing flags). Can be - null. - Quiet NaN if this object or the other object is NaN, or 0 - if both objects have the same value, or -1 if this object is less - than the other value, or 1 if this object is greater. - This implementation returns a positive number if 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.. - - - Returns a number with the same value as this one, but - copying the sign (positive or negative) of another number. (This - method is similar to the "copy-sign" operation in the General - Decimal Arithmetic Specification, except this method does not - necessarily return a copy of this object.). - A number whose sign will be copied. - An arbitrary-precision binary floating-point - number. - The parameter is null. - - - Divides this arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns the result; returns NaN instead if the result would - have a nonterminating binary expansion (including 1/3, 1/12, 1/7, - 2/3, and so on); if this is not desired, use DivideToExponent, or - use the Divide overload that takes an EContext. - The number to divide by. - The result of dividing this arbitrary-precision binary - floating-point number by another arbitrary-precision binary - floating-point number. Returns infinity if the divisor (this - arbitrary-precision binary floating-point number) is 0 and the - dividend (the other arbitrary-precision binary floating-point - number) is nonzero. Returns not-a-number (NaN) if the divisor and - the dividend are 0. Returns NaN if the result can't be exact - because it would have a nonterminating binary expansion (examples - include 1 divided by any multiple of 3, such as 1/3 or 1/12). If - this is not desired, use DivideToExponent instead, or use the - Divide overload that takes an EContext (such as - EContext.Binary64 ) instead. - - - Divides this arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns the result. - The number to divide by. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The result of dividing this arbitrary-precision binary - floating-point number by another arbitrary-precision binary - floating-point number. Signals FlagDivideByZero and returns - infinity if the divisor (this arbitrary-precision binary - floating-point number) is 0 and the dividend (the other - arbitrary-precision binary floating-point number) is nonzero. - Signals FlagInvalid and returns not-a-number (NaN) if the divisor - and the dividend are 0; or, either is null - or 's precision is 0, and the result would - have a nonterminating decimal expansion (examples include 1 divided - by any multiple of 3, such as 1/3 or 1/12); or, the rounding mode - is ERounding.None and the result is not exact. - - - Calculates the quotient and remainder using the - DivideToIntegerNaturalScale and the formula in - RemainderNaturalScale. - The number to divide by. - A 2 element array consisting of the quotient and remainder - in that order. - - - Calculates the quotient and remainder using the - DivideToIntegerNaturalScale and the formula in - RemainderNaturalScale. - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only in the division portion of the remainder - calculation; as a result, it's possible for the remainder to have a - higher precision than given in this context. Flags will be set on - the given context only if the context's HasFlags is true and - the integer part of the division result doesn't fit the precision - and exponent range without rounding. Can be null, in which the - precision is unlimited and no additional rounding, other than the - rounding down to an integer after division, is needed. - A 2 element array consisting of the quotient and remainder - in that order. - - - Divides two arbitrary-precision binary floating-point - numbers, and gives a particular exponent to the result. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual radix - point (so a negative number means the number of binary digit places - to round to). A positive number places the cutoff point to the left - of the usual radix point. - An arithmetic context object to control the - rounding mode to use if the result must be scaled down to have the - same exponent as this value. If the precision given in the context - is other than 0, calls the Quantize method with both arguments - equal to the result of the operation (and can signal FlagInvalid - and return NaN if the result doesn't fit the given precision). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the default - rounding mode is HalfEven. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the context defines an exponent range and the - desired exponent is outside that range. Signals FlagInvalid and - returns not-a-number (NaN) if the rounding mode is ERounding.None - and the result is not exact. - - - Divides two arbitrary-precision binary floating-point - numbers, and gives a particular exponent to the result. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual radix - point (so a negative number means the number of binary digit places - to round to). A positive number places the cutoff point to the left - of the usual radix point. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Divides two arbitrary-precision binary floating-point - numbers, and gives a particular exponent to the result. - The number to divide by. - The desired exponent. A negative number - places the cutoff point to the right of the usual radix point (so a - negative number means the number of binary digit places to round - to). A positive number places the cutoff point to the left of the - usual radix point. - An arithmetic context object to control the - rounding mode to use if the result must be scaled down to have the - same exponent as this value. If the precision given in the context - is other than 0, calls the Quantize method with both arguments - equal to the result of the operation (and can signal FlagInvalid - and return NaN if the result doesn't fit the given precision). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the default - rounding mode is HalfEven. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the context defines an exponent range and the - desired exponent is outside that range. Signals FlagInvalid and - returns not-a-number (NaN) if the rounding mode is ERounding.None - and the result is not exact. - - - Divides two arbitrary-precision binary floating-point - numbers, and gives a particular exponent to the result. - The number to divide by. - The desired exponent. A negative - number places the cutoff point to the right of the usual radix - point (so a negative number means the number of binary digit places - to round to). A positive number places the cutoff point to the left - of the usual radix point. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two objects. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Returns not-a-number (NaN) if the divisor and the dividend - are 0. Returns NaN if the rounding mode is ERounding.None and the - result is not exact. - - - Divides two arbitrary-precision binary floating-point - numbers, and returns the integer part of the result, rounded down, - with the preferred exponent set to this value's exponent minus the - divisor's exponent. - The number to divide by. - The integer part of the quotient of the two objects. - Signals FlagDivideByZero and returns infinity if the divisor is 0 - and the dividend is nonzero. Signals FlagInvalid and returns - not-a-number (NaN) if the divisor and the dividend are 0. - - - Divides this object by another object, and returns the - integer part of the result (which is initially rounded down), with - the preferred exponent set to this value's exponent minus the - divisor's exponent. - An arbitrary-precision binary floating-point - number. - The parameter is an - EContext object. - The integer part of the quotient of the two objects. - Signals FlagInvalid and returns not-a-number (NaN) if the return - value would overflow the exponent range. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Divides this object by another object, and returns the - integer part of the result, with the exponent set to 0. - The number to divide by. - An arithmetic context object to control the - precision. The rounding and exponent range settings of this context - are ignored. If HasFlags of the context is true, will also - store the flags resulting from the operation (the flags are in - addition to the pre-existing flags). Can be null, in which case the - precision is unlimited. - The integer part of the quotient of the two objects. The - exponent will be set to 0. Signals FlagDivideByZero and returns - infinity if the divisor is 0 and the dividend is nonzero. Signals - FlagInvalid and returns not-a-number (NaN) if the divisor and the - dividend are 0, or if the result doesn't fit the given - precision. - - - Divides this object by another binary floating-point - number and returns a result with the same exponent as this object - (the dividend). - The number to divide by. - The rounding mode to use if the result must - be scaled down to have the same exponent as this value. - The quotient of the two numbers. Signals FlagDivideByZero - and returns infinity if the divisor is 0 and the dividend is - nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the - divisor and the dividend are 0. Signals FlagInvalid and returns - not-a-number (NaN) if the rounding mode is ERounding.None and the - result is not exact. - - - Divides this arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns a two-item array containing the result of the division - and the remainder, in that order. The result of division is - calculated as though by DivideToIntegerNaturalScale, and - the remainder is calculated as though by - RemainderNaturalScale. - The number to divide by. - An array of two items: the first is the result of the - division as an arbitrary-precision binary floating-point number, - and the second is the remainder as an arbitrary-precision binary - floating-point number. The result of division is the result of the - method on the two operands, and the remainder is the result of the - Remainder method on the two operands. - - - Divides this arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns a two-item array containing the result of the division - and the remainder, in that order. The result of division is - calculated as though by DivideToIntegerNaturalScale, and - the remainder is calculated as though by - RemainderNaturalScale. - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only in the division portion of the remainder - calculation; as a result, it's possible for the remainder to have a - higher precision than given in this context. Flags will be set on - the given context only if the context's HasFlags is true and - the integer part of the division result doesn't fit the precision - and exponent range without rounding. Can be null, in which the - precision is unlimited and no additional rounding, other than the - rounding down to an integer after division, is needed. - An array of two items: the first is the result of the - division as an arbitrary-precision binary floating-point number, - and the second is the remainder as an arbitrary-precision binary - floating-point number. The result of division is the result of the - method on the two operands, and the remainder is the result of the - Remainder method on the two operands. - - - Determines whether this object's significand, exponent, - and properties are equal to those of another object. Not-a-number - values are considered equal if the rest of their properties are - equal. - An arbitrary-precision binary floating-point - number. - true if this object's significand and exponent are - equal to those of another object; otherwise, false. - - - Determines whether this object's significand, exponent, - and properties are equal to those of another object and that other - object is an arbitrary-precision binary floating-point number. - Not-a-number values are considered equal if the rest of their - properties are equal. - The parameter is an - arbitrary object. - true if the objects are equal; otherwise, - false. In this method, two objects are not equal if they - don't have the same type or if one is null and the other - isn't. - - - Determines whether this object's significand and exponent - are equal to those of another object. - An arbitrary-precision binary - floating-point number. - true if this object's significand and exponent are - equal to those of another object; otherwise, false. - - - Finds e (the base of natural logarithms) raised to the - power of this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the exponential function's - results are generally not exact. (Unlike in the General Binary - Arithmetic Specification, any rounding mode is allowed.). - Exponential of this object. If this object's value is 1, - returns an approximation to " e" within the given precision. - Signals FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Finds e (the base of natural logarithms) raised to the - power of this object's value, and subtracts the result by 1 and - returns the final result, in a way that avoids loss of precision if - the true result is very close to 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the exponential function's - results are generally not exact. (Unlike in the General Binary - Arithmetic Specification, any rounding mode is allowed.). - Exponential of this object, minus 1. Signals FlagInvalid - and returns not-a-number (NaN) if the parameter is null or the precision is unlimited (the context's - Precision property is 0). - - - Calculates this object's hash code. No application or - process IDs are used in the hash code calculation. - A 32-bit signed integer. - - - Gets a value indicating whether this object is positive or - negative infinity. - true if this object is positive or negative - infinity; otherwise, false. - - - Gets a value indicating whether this object is not a - number (NaN). - true if this object is not a number (NaN); - otherwise, false. - - - Returns whether this object is negative - infinity. - true if this object is negative infinity; - otherwise, false. - - - Returns whether this object is positive - infinity. - true if this object is positive infinity; - otherwise, false. - - - Gets a value indicating whether this object is a quiet - not-a-number value. - true if this object is a quiet not-a-number value; - otherwise, false. - - - Gets a value indicating whether this object is a signaling - not-a-number value. - true if this object is a signaling not-a-number - value; otherwise, false. - - - Finds the natural logarithm of this object, that is, the - power (exponent) that e (the base of natural logarithms) must be - raised to in order to equal this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the ln function's results are - generally not exact. (Unlike in the General Binary Arithmetic - Specification, any rounding mode is allowed.). - Ln(this object). Signals the flag FlagInvalid and returns - NaN if this object is less than 0 (the result would be a complex - number with a real part equal to Ln of this object's absolute value - and an imaginary part equal to pi, but the return value is still - NaN.). Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null or the precision is - unlimited (the context's Precision property is 0). Signals no flags - and returns negative infinity if this object's value is - 0. - - - Finds the base-10 logarithm of this object, that is, the - power (exponent) that the number 10 must be raised to in order to - equal this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the ln function's results are - generally not exact. (Unlike in the General Binary Arithmetic - Specification, any rounding mode is allowed.). - Ln(this object)/Ln(10). Signals the flag FlagInvalid and - returns not-a-number (NaN) if this object is less than 0. Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Adds 1 to this object's value and finds the natural - logarithm of the result, in a way that avoids loss of precision - when this object's value is between 0 and 1. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the ln function's results are - generally not exact. (Unlike in the General Binary Arithmetic - Specification, any rounding mode is allowed.). - Ln(1+(this object)). Signals the flag FlagInvalid and - returns NaN if this object is less than -1 (the result would be a - complex number with a real part equal to Ln of 1 plus this object's - absolute value and an imaginary part equal to pi, but the return - value is still NaN.). Signals FlagInvalid and returns not-a-number - (NaN) if the parameter is null or the - precision is unlimited (the context's Precision property is 0). - Signals no flags and returns negative infinity if this object's - value is 0. - - - Finds the base-N logarithm of this object, that is, the - power (exponent) that the number N must be raised to in order to - equal this object's value. - The parameter - is a Numbers.EFloat object. - The parameter is a - Numbers.EContext object. - Ln(this object)/Ln(baseValue). Signals the flag - FlagInvalid and returns not-a-number (NaN) if this object is less - than 0. Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null or the precision is - unlimited (the context's Precision property is 0). - The parameter is null. - - - Returns a number similar to this number but with the radix - point moved to the left. - The number of binary digit places to move the - radix point to the left. If this number is negative, instead moves - the radix point to the right by this number's absolute - value. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the left. - The number of binary digit places to move the - radix point to the left. If this number is negative, instead moves - the radix point to the right by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the left. - The number of binary digit places to move - the radix point to the left. If this number is negative, instead - moves the radix point to the right by this number's absolute - value. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the left. - The number of binary digit places to move - the radix point to the left. If this number is negative, instead - moves the radix point to the right by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is decreased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the right. - The number of binary digit places to move the - radix point to the right. If this number is negative, instead moves - the radix point to the left by this number's absolute - value. - A number whose exponent is increased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the right. - The number of binary digit places to move the - radix point to the right. If this number is negative, instead moves - the radix point to the left by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is increased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the right. - The number of binary digit places to move - the radix point to the right. If this number is negative, instead - moves the radix point to the left by this number's absolute - value. - A number whose exponent is increased by , but not to more than 0. - - - Returns a number similar to this number but with the radix - point moved to the right. - The number of binary digit places to move - the radix point to the right. If this number is negative, instead - moves the radix point to the left by this number's absolute - value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - A number whose exponent is increased by , but not to more than 0. - - - Multiplies this arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns the result. The exponent for the result is this - arbitrary-precision binary floating-point number's exponent plus - the other arbitrary-precision binary floating-point number's - exponent. - Another binary floating-point - number. - The product of the two numbers, that is, this - arbitrary-precision binary floating-point number times another - arbitrary-precision binary floating-point number. - The parameter is null. - - - Multiplies this arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns the result. - Another binary floating-point number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - The product of the two numbers, that is, this - arbitrary-precision binary floating-point number times another - arbitrary-precision binary floating-point number. - - - Multiplies by one binary floating-point number, and then - adds another binary floating-point number. - The value to multiply. - The value to add. - An arbitrary-precision binary floating-point - number. - - - Multiplies by one value, and then adds another - value. - The value to multiply. - The value to add. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. If the precision doesn't indicate a simplified - arithmetic, rounding and precision/exponent adjustment is done only - once, namely, after multiplying and adding. - The result thisValue * multiplicand + augend. - - - Multiplies by one value, and then subtracts another - value. - The value to multiply. - The value to subtract. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. If the precision doesn't indicate a simplified - arithmetic, rounding and precision/exponent adjustment is done only - once, namely, after multiplying and subtracting. - The result thisValue * multiplicand - - subtrahend. - The parameter or is null. - - - Gets an object with the same value as this one, but with - the sign reversed. - An arbitrary-precision binary floating-point number. If - this value is positive zero, returns negative zero. Returns - signaling NaN if this value is signaling NaN. (In this sense, this - method is similar to the "copy-negate" operation in the General - Decimal Arithmetic Specification, except this method does not - necessarily return a copy of this object.). - - - Returns a binary floating-point number with the same value - as this object but with the sign reversed. - An arithmetic context to control the - precision, rounding, and exponent range of the result. If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which case the precision is - unlimited and rounding isn't needed. - An arbitrary-precision binary floating-point number. If - this value is positive zero, returns positive zero. Signals - FlagInvalid and returns quiet NaN if this value is signaling - NaN. - - - Finds the largest value that's smaller than the given - value. - An arithmetic context object to control the - precision and exponent range of the result. The rounding mode from - this context is ignored. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). - Returns the largest value that's less than the given - value. Returns negative infinity if the result is negative - infinity. Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null, the precision is 0, or - has an unlimited exponent range. - - - Finds the smallest value that's greater than the given - value. - An arithmetic context object to control the - precision and exponent range of the result. The rounding mode from - this context is ignored. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). - Returns the smallest value that's greater than the given - value.Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null, the precision is 0, or - has an unlimited exponent range. - - - Finds the next value that is closer to the other object's - value than this object's value. Returns a copy of this value with - the same sign as the other value if both values are - equal. - An arbitrary-precision binary - floating-point number that the return value will approach. - An arithmetic context object to control the - precision and exponent range of the result. The rounding mode from - this context is ignored. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). - Returns the next value that is closer to the other object' - s value than this object's value. Signals FlagInvalid and returns - NaN if the parameter is null, the precision - is 0, or has an unlimited exponent - range. - - - Rounds this object's value to a given precision, using the - given rounding mode and range of exponent, and also converts - negative zero to positive zero. The idiom - EDecimal.SignalingNaN.Plus(ctx) is useful for triggering an - invalid operation and returning not-a-number (NaN) for custom - arithmetic operations. - A context for controlling the precision, rounding - mode, and exponent range. Can be null, in which case the precision - is unlimited and rounding isn't needed. - The closest value to this object's value, rounded to the - specified precision. If is null or the - precision and exponent range are unlimited, returns the same value - as this object (or a quiet NaN if this object is a signaling - NaN). - - - Raises this object's value to the given exponent, using - unlimited precision. - An arbitrary-precision binary floating-point - number expressing the exponent to raise this object's value - to. - This^exponent. Returns not-a-number (NaN) if the exponent - has a fractional part. - - - Raises this object's value to the given - exponent. - An arbitrary-precision binary floating-point - number expressing the exponent to raise this object's value - to. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - This^exponent. Signals the flag FlagInvalid and returns - NaN if this object and exponent are both 0; or if this value is - less than 0 and the exponent either has a fractional part or is - infinity. Signals FlagInvalid and returns not-a-number (NaN) if the - parameter is null or the precision is - unlimited (the context's Precision property is 0), and the exponent - has a fractional part. - - - Raises this object's value to the given - exponent. - The exponent to raise this object's - value to. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - This^exponent. Signals the flag FlagInvalid and returns - NaN if this object and exponent are both 0. - - - Raises this object's value to the given - exponent. - The exponent to raise this object's - value to. - This^exponent. Returns not-a-number (NaN) if this object - and exponent are both 0. - - - Finds the number of digits in this number's significand. - Returns 1 if this value is 0, and 0 if this value is infinity or - not-a-number (NaN). - An arbitrary-precision integer. - - - Returns whether this object's value is an - integer. - true if this object's value is an integer; - otherwise, false. - - - - Returns a binary floating-point number with the same - value but a new exponent. - Note that this is not always the same as rounding to a given - number of binary digit places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - binary digit places is desired, it's better to use the - RoundToExponent and RoundToIntegral methods instead. - Remark: - This method can be used to implement - fixed-point binary arithmetic, in which each binary floating-point - number has a fixed number of digits after the radix point. The - following code example returns a fixed-point number with up to 20 - digits before and exactly 5 digits after the radix point: - /* After performing arithmetic operations, adjust - /* the number to 5 /* - */*/*/ - digits after the radix point number = number.Quantize( - EInteger.FromInt32(-5), /* five digits after the radix - point*/ - EContext.ForPrecision(25) /* 25-digit - precision);*/ - A fixed-point binary arithmetic in which no digits come after - the radix point (a desired exponent of 0) is considered an "integer - arithmetic". - - The desired exponent for the result. - The exponent is the number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control precision and - rounding of the result. If HasFlags - of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - A binary floating-point number with the same value as this - object but with the exponent changed. Signals FlagInvalid and - returns not-a-number (NaN) if this object is infinity, if the - rounded result can't fit the given precision, or if the context - defines an exponent range and the given exponent is outside that - range. - - - - Returns a binary floating-point number with the same - value but a new exponent. - Note that this is not always the same as rounding to a given - number of binary digit places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - binary digit places is desired, it's better to use the - RoundToExponent and RoundToIntegral methods instead. - Remark: - This method can be used to implement - fixed-point binary arithmetic, in which each binary floating-point - number has a fixed number of digits after the radix point. The - following code example returns a fixed-point number with up to 20 - digits before and exactly 5 digits after the radix point: - /* After performing arithmetic operations, adjust - /* the number to 5*/*/ - digits after the radix point number = number.Quantize(-5, /* five - digits*/ - after the radix point EContext.ForPrecision(25) /* 25-digit - precision);*/ - A fixed-point binary arithmetic in which no digits come after - the radix point (a desired exponent of 0) is considered an "integer - arithmetic". - - The desired exponent for the - result. The exponent is the number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control precision and - rounding of the result. If HasFlags - of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - A binary floating-point number with the same value as this - object but with the exponent changed. Signals FlagInvalid and - returns not-a-number (NaN) if this object is infinity, if the - rounded result can't fit the given precision, or if the context - defines an exponent range and the given exponent is outside that - range. - - - Returns a binary floating-point number with the same value - as this object but with the same exponent as another binary - floating-point number. - Note that this is not always the same as rounding to a given - number of binary digit places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - binary digit places is desired, it's better to use the - RoundToExponent and RoundToIntegral methods instead. - Remark: This method can be used to implement - fixed-point binary arithmetic, in which a fixed number of digits - come after the radix point. A fixed-point binary arithmetic in - which no digits come after the radix point (a desired exponent of - 0) is considered an "integer arithmetic" . - A binary floating-point number containing - the desired exponent of the result. The significand is ignored. The - exponent is the number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the sixteenth (10b^-3, 0.0001b), and 3 means round - to the sixteen-place (10b^3, 1000b). A value of 0 rounds the number - to an integer. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - A binary floating-point number with the same value as this - object but with the exponent changed. Signals FlagInvalid and - returns not-a-number (NaN) if the result can't fit the given - precision without rounding, or if the arithmetic context defines an - exponent range and the given exponent is outside that - range. - - - Returns an object with the same numerical value as this - one but with trailing zeros removed from its significand. For - example, 1.00 becomes 1. - If this object's value is 0, changes the exponent to - 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and rounding - isn't needed. - This value with trailing zeros removed. Note that if the - result has a very high exponent and the context says to clamp high - exponents, there may still be some trailing zeros in the - significand. - - - Returns the remainder that would result when this - arbitrary-precision binary floating-point number is divided by - another arbitrary-precision binary floating-point number. The - remainder is the number that remains when the absolute value of - this arbitrary-precision binary floating-point number is divided - (as though by DivideToIntegerZeroScale) by the absolute value of - the other arbitrary-precision binary floating-point number; the - remainder has the same sign (positive or negative) as this - arbitrary-precision binary floating-point number. - An arbitrary-precision binary floating-point - number. - The parameter is an - EContext object. - The remainder that would result when this - arbitrary-precision binary floating-point number is divided by - another arbitrary-precision binary floating-point number. Signals - FlagDivideByZero and returns infinity if the divisor (this - arbitrary-precision binary floating-point number) is 0 and the - dividend (the other arbitrary-precision binary floating-point - number) is nonzero. Signals FlagInvalid and returns not-a-number - (NaN) if the divisor and the dividend are 0, or if the result of - the division doesn't fit the given precision. - - - Finds the remainder that results when dividing two - arbitrary-precision binary floating-point numbers. The remainder is - the value that remains when the absolute value of this object is - divided by the absolute value of the other object; the remainder - has the same sign (positive or negative) as this object's - value. - An arbitrary-precision binary floating-point - number. - The parameter is an - EContext object. - The remainder of the two numbers. Signals FlagInvalid and - returns not-a-number (NaN) if the divisor is 0, or if the result - doesn't fit the given precision. - - - Calculates the remainder of a number by the formula - "this" - (("this" / "divisor") * "divisor"). - The number to divide by. - An arbitrary-precision binary floating-point - number. - - - Calculates the remainder of a number by the formula "this" - - (("this" / "divisor") * "divisor"). - The number to divide by. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only in the division portion of the remainder - calculation; as a result, it's possible for the return value to - have a higher precision than given in this context. Flags will be - set on the given context only if the context's HasFlags is - true and the integer part of the division result doesn't fit the - precision and exponent range without rounding. Can be null, in - which the precision is unlimited and no additional rounding, other - than the rounding down to an integer after division, is - needed. - An arbitrary-precision binary floating-point - number. - - - Finds the distance to the closest multiple of the given - divisor, based on the result of dividing this object's value by - another object's value. - - If this and the other object divide evenly, the result is - 0. - If the remainder's absolute value is less than half of the - divisor's absolute value, the result has the same sign as this - object and will be the distance to the closest multiple. - If the remainder's absolute value is more than half of the - divisor's absolute value, the result has the opposite sign of this - object and will be the distance to the closest multiple. - If the remainder's absolute value is exactly half of the - divisor's absolute value, the result has the opposite sign of this - object if the quotient, rounded down, is odd, and has the same sign - as this object if the quotient, rounded down, is even, and the - result's absolute value is half of the divisor's absolute - value. This function is also known as the "IEEE - Remainder" function. - The number to divide by. - An arithmetic context object to control the - precision. The rounding and exponent range settings of this context - are ignored (the rounding mode is always treated as HalfEven). If - HasFlags of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null, in which the precision is - unlimited. - The distance of the closest multiple. Signals FlagInvalid - and returns not-a-number (NaN) if the divisor is 0, or either the - result of integer division (the quotient) or the remainder wouldn't - fit the given precision. - - - Returns a binary floating-point number with the same value - as this object but rounded to a new exponent if necessary. The - resulting number's Exponent property will not necessarily be the - given exponent; use the Quantize method instead to give the result - a particular exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - A binary floating-point number rounded to the closest - value representable in the given precision. If the result can't fit - the precision, additional digits are discarded to make it fit. - Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to the given exponent when rounding, and the given - exponent is outside of the valid range of the arithmetic - context. - - - Returns a binary floating-point number with the same value - as this object but rounded to a new exponent if necessary. The - resulting number's Exponent property will not necessarily be the - given exponent; use the Quantize method instead to give the result - a particular exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - A binary floating-point number rounded to the closest - value representable in the given precision. If the result can't fit - the precision, additional digits are discarded to make it fit. - Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to the given exponent when rounding, and the given - exponent is outside of the valid range of the arithmetic - context. - - - Returns a binary floating-point number with the same value - as this object but rounded to the given exponent, and signals an - inexact flag if the result would be inexact. The resulting number's - Exponent property will not necessarily be the given exponent; use - the Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - A binary floating-point number rounded to the closest - value representable in the given precision. Signals FlagInvalid and - returns not-a-number (NaN) if the result can't fit the given - precision without rounding. Signals FlagInvalid and returns - not-a-number (NaN) if the arithmetic context defines an exponent - range, the new exponent must be changed to the given exponent when - rounding, and the given exponent is outside of the valid range of - the arithmetic context. - - - Returns a binary number with the same value as this object - but rounded to the given exponent. The resulting number's Exponent - property will not necessarily be the given exponent; use the - Quantize method instead to give the result a particular - exponent. - The minimum exponent the result can have. - This is the maximum number of fractional digits in the result, - expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the eighth (10^-1, 1/8), and 3 means round to the - eight (2^3, 8). A value of 0 rounds the number to an - integer. - Desired mode for rounding this object's - value. - A binary number rounded to the closest value representable - in the given precision. - - - Returns a binary floating-point number with the same value - as this object but rounded to the given exponent represented as a - 32-bit signed integer, and signals an inexact flag if the result - would be inexact. The resulting number's Exponent property will not - necessarily be the given exponent; use the Quantize method instead - to give the result a particular exponent. - The minimum exponent the result can - have. This is the maximum number of fractional digits in the - result, expressed as a negative number. Can also be positive, which - eliminates lower-order places from the number. For example, -3 - means round to the thousandth (10^-3, 0.0001), and 3 means round to - the thousand (10^3, 1000). A value of 0 rounds the number to an - integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - A binary floating-point number rounded to the closest - value representable in the given precision. Signals FlagInvalid and - returns not-a-number (NaN) if the result can't fit the given - precision without rounding. Signals FlagInvalid and returns - not-a-number (NaN) if the arithmetic context defines an exponent - range, the new exponent must be changed to the given exponent when - rounding, and the given exponent is outside of the valid range of - the arithmetic context. - - - Returns a binary floating-point number with the same value - as this object but rounded to an integer, and signals an inexact - flag if the result would be inexact. The resulting number's - Exponent property will not necessarily be 0; use the Quantize - method instead to give the result an exponent of 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - A binary floating-point number rounded to the closest - integer representable in the given precision. Signals FlagInvalid - and returns not-a-number (NaN) if the result can't fit the given - precision without rounding. Signals FlagInvalid and returns - not-a-number (NaN) if the arithmetic context defines an exponent - range, the new exponent must be changed to 0 when rounding, and 0 - is outside of the valid range of the arithmetic context. - - - Returns a binary floating-point number with the same value - as this object but rounded to an integer, without adding the - FlagInexact or FlagRounded flags. The resulting - number's Exponent property will not necessarily be 0; use the - Quantize method instead to give the result an exponent of - 0. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags), except that this - function will never add the FlagRounded and - FlagInexact flags (the only difference between this and - RoundToExponentExact). Can be null, in which case the default - rounding mode is HalfEven. - A binary floating-point number rounded to the closest - integer representable in the given precision. If the result can't - fit the precision, additional digits are discarded to make it fit. - Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to 0 when rounding, and 0 is outside of the valid range - of the arithmetic context. - - - Returns a binary floating-point number with the same value - as this object but rounded to an integer, and signals an inexact - flag if the result would be inexact. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the default rounding mode is - HalfEven. - A binary floating-point number rounded to the closest - integer representable in the given precision. Signals FlagInvalid - and returns not-a-number (NaN) if the result can't fit the given - precision without rounding. Signals FlagInvalid and returns - not-a-number (NaN) if the arithmetic context defines an exponent - range, the new exponent must be changed to 0 when rounding, and 0 - is outside of the valid range of the arithmetic context. - - - Returns a binary floating-point number with the same value - as this object but rounded to an integer, without adding the - FlagInexact or FlagRounded flags. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags), except that this - function will never add the FlagRounded and - FlagInexact flags (the only difference between this and - RoundToExponentExact). Can be null, in which case the default - rounding mode is HalfEven. - A binary floating-point number rounded to the closest - integer representable in the given precision. If the result can't - fit the precision, additional digits are discarded to make it fit. - Signals FlagInvalid and returns not-a-number (NaN) if the - arithmetic context defines an exponent range, the new exponent must - be changed to 0 when rounding, and 0 is outside of the valid range - of the arithmetic context. - - - Rounds this object's value to a given precision, using the - given rounding mode and range of exponent. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The closest value to this object's value, rounded to the - specified precision. Returns the same value as this object if - is null or the precision and exponent range - are unlimited. - - - Returns a number in which the value of this object is - rounded to fit the maximum precision allowed if it has more - significant digits than the maximum precision. The maximum - precision allowed is given in an arithmetic context. This method is - designed for preparing operands to a custom arithmetic operation in - accordance with the "simplified" arithmetic given in Appendix A of - the General Decimal Arithmetic Specification. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited. Signals the - flag LostDigits if the input number has greater precision than - allowed and was rounded to a different numerical value in order to - fit the precision. - This object rounded to the given precision. Returns this - object and signals no flags if is null or - specifies an unlimited precision, if this object is infinity or - not-a-number (including signaling NaN), or if the number's value - has no more significant digits than the maximum precision given in - . - - - Returns a number similar to this number but with the scale - adjusted. - The parameter is a - 32-bit signed integer. - An arbitrary-precision binary floating-point - number. - - - Returns a number similar to this number but with the scale - adjusted. - The parameter is a - 32-bit signed integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null. - An arbitrary-precision binary floating-point - number. - - - Returns a number similar to this number but with the scale - adjusted. - An arbitrary-precision integer. - A number whose exponent is increased by . - - - Returns a number similar to this number but with its scale - adjusted. - An arbitrary-precision integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null. - An arbitrary-precision binary floating-point - number. - The parameter is null. - - - Finds the square root of this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the square root function's - results are generally not exact for many inputs. (Unlike in the - General Binary Arithmetic Specification, any rounding mode is - allowed.). - The square root. Signals the flag FlagInvalid and returns - NaN if this object is less than 0 (the square root would be a - complex number, but the return value is still NaN). Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Finds the square root of this object's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - This parameter can't be null, as the square root function's - results are generally not exact for many inputs. (Unlike in the - General Binary Arithmetic Specification, any rounding mode is - allowed.). - The square root. Signals the flag FlagInvalid and returns - NaN if this object is less than 0 (the square root would be a - complex number, but the return value is still NaN). Signals - FlagInvalid and returns not-a-number (NaN) if the parameter - is null or the precision is unlimited (the - context's Precision property is 0). - - - Subtracts an arbitrary-precision binary floating-point - number from this arbitrary-precision binary floating-point number - and returns the result. The exponent for the result is the lower of - this arbitrary-precision binary floating-point number's exponent - and the other arbitrary-precision binary floating-point number's - exponent. - The number to subtract from this - instance's value. - The difference between the two numbers, that is, this - arbitrary-precision binary floating-point number minus another - arbitrary-precision binary floating-point number. If this - arbitrary-precision binary floating-point number is not-a-number - (NaN), returns NaN. - - - Subtracts an arbitrary-precision binary floating-point - number from this arbitrary-precision binary floating-point number - and returns the result. - The number to subtract from this - instance's value. - An arithmetic context to control the precision, - rounding, and exponent range of the result. If HasFlags of - the context is true, will also store the flags resulting from the - operation (the flags are in addition to the pre-existing flags). - Can be null, in which case the precision is unlimited and no - rounding is needed. - The difference between the two numbers, that is, this - arbitrary-precision binary floating-point number minus another - arbitrary-precision binary floating-point number. If this - arbitrary-precision binary floating-point number is not-a-number - (NaN), returns NaN. - The parameter is null. - - - Converts this value to a 64-bit floating-point number - encoded in the IEEE 754 binary64 format. - This number, converted to a 64-bit floating-point number - encoded in the IEEE 754 binary64 format. The return value can be - positive infinity or negative infinity if this value exceeds the - range of a 64-bit floating point number. - - - Converts this value to its closest equivalent as 32-bit - floating-point number, expressed as an integer in the IEEE 754 - binary32 format. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. - The closest 32-bit binary floating-point number to this - value, expressed as an integer in the IEEE 754 binary32 format. The - return value can be positive infinity or negative infinity if this - value exceeds the range of a 32-bit floating point - number. - - - Converts this value to its closest equivalent as a 64-bit - floating-point number, expressed as an integer in the IEEE 754 - binary64 format. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 64-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. - The closest 64-bit binary floating-point number to this - value, expressed as an integer in the IEEE 754 binary64 format. The - return value can be positive infinity or negative infinity if this - value exceeds the range of a 64-bit floating point - number. - - - Converts this value to an arbitrary-precision decimal - number. - This number, converted to an arbitrary-precision decimal - number. - - - Converts this value to an arbitrary-precision integer. Any - fractional part of this value will be discarded when converting to - an arbitrary-precision integer. Note that depending on the value, - especially the exponent, generating the arbitrary-precision integer - may require a huge amount of memory. Use the ToSizedEInteger method - to convert a number to an EInteger only if the integer fits in a - bounded bit range; that method will throw an exception on - overflow. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - - - Converts this value to an arbitrary-precision integer, - checking whether the value contains a fractional part. Note that - depending on the value, especially the exponent, generating the - arbitrary-precision integer may require a huge amount of memory. - Use the ToSizedEIntegerIfExact method to convert a number to an - EInteger only if the integer fits in a bounded bit range; that - method will throw an exception on overflow. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - This object's value is not an - exact integer. - - - Converts this value to an arbitrary-precision integer, - checking whether the value contains a fractional part. Note that - depending on the value, especially the exponent, generating the - arbitrary-precision integer may require a huge amount of memory. - Use the ToSizedEIntegerIfExact method to convert a number to an - EInteger only if the integer fits in a bounded bit range; that - method will throw an exception on overflow. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - This object's value is not an - exact integer. - - - Converts this value to an arbitrary-precision decimal - number, then returns the value of that decimal's - ToEngineeringString method. - A text string. - - - Converts this value to an arbitrary-precision decimal - number. - An arbitrary-precision decimal number. - - - Converts this value to a string, but without exponential - notation. - A text string. - - - Returns a string representation of this number's value - after rounding that value to the given precision (using the given - arithmetic context, such as EContext.Binary64 - ). If the - number after rounding is neither infinity nor not-a-number (NaN), - returns the shortest decimal form of this number's value (in terms - of decimal digits starting with the first nonzero digit and ending - with the last nonzero digit) that results in the rounded number - after the decimal form is converted to binary floating-point format - (using the given arithmetic context). - An arithmetic context to control precision (in - bits), rounding, and exponent range of the rounded number. If - HasFlags - of the context is true, will also store the flags - resulting from the operation (the flags are in addition to the - pre-existing flags). Can be null. If this parameter is null or - defines no maximum precision, returns the same value as the - ToString() method. - Shortest decimal form of this number's value for the given - arithmetic context. The text string will be in exponential notation - (expressed as a number 1 or greater, but less than 10, times a - power of 10) if the number's first nonzero decimal digit is more - than five digits after the decimal point, or if the number's - exponent is greater than 0 and its value is 10, 000, 000 or - greater. - - The following example converts an EFloat number to its - shortest round-tripping decimal form using the same precision as - the double - type in Java and.NET: - String str = efloat.ToShortestString(EContext.Binary64); - - - - Converts this value to its closest equivalent as a 32-bit - floating-point number. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The closest 32-bit binary floating-point number to this - value. The return value can be positive infinity or negative - infinity if this value exceeds the range of a 32-bit floating point - number. - - - Converts this number's value to a text string. - A string representation of this object. The value is - converted to a decimal number (using the EDecimal.FromEFloat - method) and the decimal form of this number's value is returned. - The text string will be in exponential notation (expressed as a - number 1 or greater, but less than 10, times a power of 10) if the - converted decimal number's exponent (EDecimal's Exponent property) - is greater than 0 or if the number's first nonzero decimal digit is - more than five digits after the decimal point. - - - Returns the unit in the last place. The significand will - be 1 and the exponent will be this number's exponent. Returns 1 - with an exponent of 0 if this number is infinity or not-a-number - (NaN). - An arbitrary-precision binary floating-point - number. - - - Converts this value to an arbitrary-precision integer by - discarding its fractional part and checking whether the resulting - integer overflows the given signed bit count. - The maximum number of signed bits the - integer can have. The integer's value may not be less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN), or this number's value, once converted to an - integer by discarding its fractional part, is less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - - - Converts this value to an arbitrary-precision integer, - only if this number's value is an exact integer and that integer - does not overflow the given signed bit count. - The maximum number of signed bits the - integer can have. The integer's value may not be less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN), or this number's value, once converted to an - integer by discarding its fractional part, is less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - This object's value is not an - exact integer. - - - This is an internal method. - A 32-bit signed integer. - - - This is an internal method. - An arbitrary-precision binary floating-point - number. - A 32-bit signed integer. - - - This is an internal method. - An arbitrary-precision binary floating-point - number. - An arbitrary-precision integer. - - - This is an internal method. - An arbitrary-precision binary floating-point - number. - An arbitrary-precision integer. - - - This is an internal method. - An arbitrary-precision integer. - The parameter - is a 32-bit signed integer. - The parameter is a 32-bit signed integer. - An IShiftAccumulator object. - - - This is an internal method. - An arbitrary-precision integer. - Another arbitrary-precision integer. - A FastInteger object. - - - This is an internal method. - Another arbitrary-precision integer. - A fast integer. - An arbitrary-precision integer. - - - This is an internal method. - An arbitrary-precision binary floating-point - number. - A 32-bit signed integer. - - - This is an internal method. - The parameter is - a Numbers.EInteger object. - The parameter is - an internal parameter. - The parameter is an - internal parameter. - An arbitrary-precision binary floating-point - number. - - - This is an internal method. - A 32-bit signed integer. - - - This is an internal method. - The parameter is a 32-bit - signed integer. - An arbitrary-precision binary floating-point - number. - - - Returns one added to this arbitrary-precision binary - floating-point number. - The given arbitrary-precision binary floating-point number - plus one. - - - Returns one subtracted from this arbitrary-precision - binary floating-point number. - The given arbitrary-precision binary floating-point number - minus one. - - - 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. - This number's value, truncated to a byte (from 0 to - 255). - 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. - - - 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). - This number, converted to a byte (from 0 to 255). Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a byte (from 0 to 255). - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 255. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - binary floating-point number. - The number to convert as a byte (from 0 to - 255). - This number's value as an arbitrary-precision binary - floating-point number. - - - 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. - This number's value, truncated to a 16-bit signed - integer. - 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. - - - 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. - This number, converted to a 16-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -32768 or - greater than 32767. - - - Converts a 16-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 16-bit signed - integer. - This number's value as an arbitrary-precision binary - floating-point number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -2147483648 - or greater than 2147483647. - - - Converts a boolean value (either true or false) to an - arbitrary-precision binary floating-point number. - Either true or false. - The number 1 if is true, - otherwise, 0. - - - Converts a 32-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 32-bit signed - integer. - This number's value as an arbitrary-precision binary - floating-point number. - - - 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. - This number's value, truncated to a 64-bit signed - integer. - 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. - - - 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. - This number, converted to a 64-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than - -9223372036854775808 or greater than - 9223372036854775807. - - - Converts an unsigned integer expressed as a 64-bit signed - integer to an arbitrary-precision binary number. - A 64-bit signed integer. If this value is - 0 or greater, the return value will represent it. If this value is - less than 0, the return value will store 2^64 plus this value - instead. - An arbitrary-precision binary number with the exponent set - to 0. If is 0 or greater, the return - value will represent it. If is less - than 0, the return value will store 2^64 plus this value - instead. - - - Converts a 64-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 64-bit signed - integer. - This number's value as an arbitrary-precision binary - floating-point number with the exponent set to 0. - - - Converts a boolean value (true or false) to an - arbitrary-precision binary floating-point number. - Either true or false. - The number 1 if is true; - otherwise, 0. - - - Creates a binary floating-point number from a 32-bit - floating-point number. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the floating point number to a string - first. - The parameter is a 32-bit - binary floating-point number. - A binary floating-point number with the same value as - . - - - Creates a binary floating-point number from a 64-bit - floating-point number. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the floating point number to a string - first. - The parameter is a 64-bit - floating-point number. - A binary floating-point number with the same value as - . - - - Converts an arbitrary-precision integer to an arbitrary - precision binary. - An arbitrary-precision integer. - An arbitrary-precision binary floating-point number with - the exponent set to 0. - - - Adds an arbitrary-precision binary floating-point number - and another arbitrary-precision binary floating-point number and - returns the result. - The first arbitrary-precision binary - floating-point number. - The second arbitrary-precision binary - floating-point number. - The sum of the two numbers, that is, an - arbitrary-precision binary floating-point number plus another - arbitrary-precision binary floating-point number. - The parameter or is - null. - - - Subtracts one arbitrary-precision binary floating-point - number from another. - The first operand. - The second operand. - The difference of the two objects. - The parameter is null. - - - Adds one to an arbitrary-precision binary floating-point - number. - An arbitrary-precision binary floating-point - number. - The number given in plus - one. - The parameter is null. - - - Subtracts one from an arbitrary-precision binary - floating-point number. - An arbitrary-precision binary floating-point - number. - The number given in minus - one. - The parameter is null. - - - Multiplies an arbitrary-precision binary floating-point - number by another arbitrary-precision binary floating-point number - and returns the result. - The first operand. - The second operand. - The product of the two numbers, that is, an - arbitrary-precision binary floating-point number times another - arbitrary-precision binary floating-point number. - The parameter is null. - - - Divides one binary floating-point number by another and - returns the result. When possible, the result will be - exact. - The number that will be divided by the - divisor. - The number to divide by. - The quotient of the two numbers. Returns infinity if the - divisor is 0 and the dividend is nonzero. Returns not-a-number - (NaN) if the divisor and the dividend are 0. Returns NaN if the - result can't be exact because it would have a nonterminating binary - expansion. If this is not desired, use DivideToExponent instead, or - use the Divide overload that takes an EContext instead. - The parameter is null. - - - Returns the remainder that would result when an - arbitrary-precision binary floating-point number is divided by - another arbitrary-precision binary floating-point number. The - remainder is the number that remains when the absolute value of an - arbitrary-precision binary floating-point number is divided (as - though by DivideToIntegerZeroScale) by the absolute value of the - other arbitrary-precision binary floating-point number; the - remainder has the same sign (positive or negative) as this - arbitrary-precision binary floating-point number. - The number that will be divided by the - divisor. - The number to divide by. - The remainder that would result when an - arbitrary-precision binary floating-point number is divided by - another arbitrary-precision binary floating-point number. - The parameter is null. - - - Gets an object with the same value as this one, but with - the sign reversed. - An arbitrary-precision binary floating-point - number. - The negated form of the given number. If the given number - is positive zero, returns negative zero. Returns signaling NaN if - this value is signaling NaN. - The parameter is null. - - - Converts an arbitrary-precision binary floating-point - number to a value to an arbitrary-precision integer. Any fractional - part in this value will be discarded when converting to an - arbitrary-precision integer. - The number to convert as an - arbitrary-precision binary floating-point number. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - The parameter is null. - - - Converts this value to its closest equivalent as a 64-bit - floating-point number. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 64-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The value to convert to a 64-bit - floating-point number. - The closest 64-bit floating-point number to this value. - The return value can be positive infinity or negative infinity if - this value exceeds the range of a 64-bit floating point - number. - The parameter is null. - - - Converts an arbitrary-precision binary floating-point - number to its closest equivalent as a 32-bit floating-point number. - The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. Unfortunately, in the.NET implementation, the return value of - this method may be a quiet NaN even if a signaling NaN would - otherwise be generated. - The number to convert as an - arbitrary-precision binary floating-point number. - The closest 32-bit binary floating-point number to this - value. The return value can be positive infinity or negative - infinity if this value exceeds the range of a 32-bit floating point - number. - The parameter is null. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - byte (from 0 to 255). - The parameter 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. - The parameter is null. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - binary floating-point number. - The number to convert as a byte (from 0 to - 255). - The value of as an - arbitrary-precision binary floating-point number. - - - 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. - This number's value, truncated to an 8-bit signed - integer. - 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. - - - 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. - This number, converted to an 8-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as an 8-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -128 or - greater than 127. - - - Converts an 8-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as an 8-bit signed - integer. - This number's value as an arbitrary-precision binary - floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to an - 8-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts an 8-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as an 8-bit signed - integer. - The value of as an - arbitrary-precision binary floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - 16-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 16-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 16-bit signed - integer. - The value of as an - arbitrary-precision binary floating-point number. - - - 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. - This number's value, truncated to a 16-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 16-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 65535. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision binary floating-point number. - The number to convert as a 16-bit - unsigned integer. - This number's value as an arbitrary-precision binary - floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - 16-bit unsigned integer. - The parameter 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. - The parameter is null. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision binary floating-point number. - The number to convert as a 16-bit - unsigned integer. - The value of as an - arbitrary-precision binary floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - 32-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision binary floating-point number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 4294967295. - - - Converts a 32-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 32-bit signed - integer. - This number's value as an arbitrary-precision binary - floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - 32-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision binary floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - 64-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 64-bit signed integer to an arbitrary-precision - binary floating-point number. - The number to convert as a 64-bit signed - integer. - The value of as an - arbitrary-precision binary floating-point number. - - - 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. - This number's value, truncated to a 64-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 64-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 18446744073709551615. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision binary floating-point number. - The number to convert as a 64-bit - unsigned integer. - This number's value as an arbitrary-precision binary - floating-point number. - - - Converts an arbitrary-precision binary floating-point - number 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. - The number to convert as an arbitrary-precision - binary floating-point number. - The value of , truncated to a - 64-bit unsigned integer. - The parameter 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. - The parameter is null. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision binary floating-point number. - The number to convert as a 64-bit - unsigned integer. - The value of as an - arbitrary-precision binary floating-point number. - - - A class that implements additional operations on - arbitrary-precision binary floating-point numbers. - - - Returns the number 2, the binary radix. - Specifies an arithmetic context for rounding the - number 2. Can be null. - The number 2, or the closest representable number to 2 in - the arithmetic context. - - - Creates a binary floating-point number from a 32-bit - signed integer. - The parameter is a 32-bit - signed integer. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - An arbitrary-precision binary floating-point number with - the closest representable value to the given integer. - - - Converts a boolean value (either true or false) to an - arbitrary-precision binary floating-point number. - Either true or false. - A context used for rounding the result. Can be - null. - Either 1 if is true, or 0 if - is false.. The result will be rounded as - specified by the given context, if any. - - - Returns whether the given arbitrary-precision number - object is in a canonical form. For the current version of EFloat, - all EFloat objects are in a canonical form. - An arbitrary-precision number object. - Always true. - - - Returns whether the given arbitrary-precision number - object is neither null nor infinity nor not-a-number - (NaN). - An arbitrary-precision number object. - Either true if the given arbitrary-precision number - object is neither null nor infinity nor not-a-number (NaN), or - false otherwise. - - - Returns whether the given arbitrary-precision number - object is positive or negative infinity. - An arbitrary-precision number object. - Either true if the given arbitrary-precision number - object is positive or negative infinity, or false - otherwise. - - - Returns whether the given arbitrary-precision number - object is a not-a-number (NaN). - An arbitrary-precision number object. - Either true or false. - - - Returns whether the given number is a - normal number. A - subnormal number is a nonzero finite number whose Exponent - property (or the number's exponent when that number is expressed in - scientific notation with one digit before the radix point) is less - than the minimum possible exponent for that number. A - normal number is nonzero and finite, but not - subnormal. - An arbitrary-precision number object. - A context specifying the exponent range of - arbitrary-precision numbers. Can be null. If AdjustExponent of the - given context is true, a nonzero number is normal if the - number's exponent (when that number is expressed in scientific - notation with one nonzero digit before the radix point) is at least - the given context's EMax property (e.g., if EMax is -100, 2.3456 * - 10 - -99 is normal, but 2.3456 * 10 - -102 is not). If AdjustExponent of the given context is - false, a nonzero number is subnormal if the number's - Exponent property is at least given context's EMax property (e.g., - if EMax is -100, 23456 * 10 - -99 is normal, but 23456 * 10 - -102 is not). - Either true if the given number is subnormal, or - false otherwise. Returns true if the given context is - null or HasExponentRange of the given context is false. - - - Returns whether the given arbitrary-precision number - object is a quiet not-a-number (NaN). - An arbitrary-precision number object. - Either true or false. - - - Returns whether the given arbitrary-precision number - object is negative (including negative infinity, negative - not-a-number [NaN], or negative zero). - An arbitrary-precision number object. - Either true or false. - - - Returns whether the given arbitrary-precision number - object is a signaling not-a-number (NaN). - An arbitrary-precision number object. - Either true or false. - - - Converts a number class identifier (ranging from 0 through - 9) to a text string. An arbitrary-precision number object can - belong in one of ten number classes. - An integer identifying a number class. - A text string identifying the given number class as - follows: 0 = "+Normal"; 1 = "-Normal", 2 = "+Subnormal", 3 = - "-Subnormal", 4 = "+Zero", 5 = "-Zero", 6 = "+Infinity", 7 = - "-Infinity", 8 = "NaN", 9 = "sNaN". - The parameter is less than 0 or greater than 9. - - - Finds the number class for an arbitrary-precision binary - number object. - An arbitrary-precision binary number - object. - A context object that specifies the precision and - exponent range of arbitrary-precision numbers. This is used only to - distinguish between normal and subnormal numbers. Can be - null. - A 32-bit signed integer identifying the given number - object, number class as follows: 0 = positive normal; 1 = negative - normal, 2 = positive subnormal, 3 = negative subnormal, 4 = - positive zero, 5 = negative zero, 6 = positive infinity, 7 = - negative infinity, 8 = quiet not-a-number (NaN), 9 = signaling - NaN. - The parameter is null. - - - Returns whether the given number is a - subnormal number. A - subnormal number is a nonzero finite number whose Exponent - property (or the number's exponent when that number is expressed in - scientific notation with one digit before the radix point) is less - than the minimum possible exponent for that number. - An arbitrary-precision number object. - A context specifying the exponent range of - arbitrary-precision numbers. Can be null. If AdjustExponent of the - given context is true, a nonzero number is subnormal if the - number's exponent (when that number is expressed in scientific - notation with one nonzero digit before the radix point) is less - than the given context's EMax property (e.g., if EMax is -100, - 2.3456 * 10 - -102 is subnormal, but 2.3456 * 10 - -99 is not). If AdjustExponent of the given context is - false, a nonzero number is subnormal if the number's - Exponent property is less than the given context's EMax property - (e.g., if EMax is -100, 23456 * 10 - -102 is subnormal, but 23456 * 10 - -99 is not). - Either true if the given number is subnormal, or - false otherwise. Returns false if the given context - is null or HasExponentRange of the given context is false. - The parameter is null. - - - Returns whether the given arbitrary-precision number - object is zero (positive zero or negative zero). - An arbitrary-precision number object. - true if the given number has a value of zero - (positive zero or negative zero); otherwise, false. - - - Returns the base-2 exponent of an arbitrary-precision - binary number (when that number is expressed in scientific notation - with one nonzero digit before the radix point). For example, - returns 3 for the numbers 1.11b * 2^3 and 111 * 2^1. - An arbitrary-precision binary number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - The base-2 exponent of the given number (when that number - is expressed in scientific notation with one nonzero digit before - the radix point). Signals DivideByZero and returns negative - infinity if is zero. Returns positive - infinity if is positive infinity or negative - infinity. - The parameter is null. - - - Finds an arbitrary-precision binary number whose binary - point is moved a given number of places. - An arbitrary-precision binary number. - The number of binary places to move the binary - point of "ed". This must be an integer with an exponent of - 0. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - The given arbitrary-precision binary number whose binary - point is moved the given number of places. Signals an invalid - operation and returns not-a-number (NaN) if - is infinity or NaN, has an Exponent property other than 0. Signals - an invalid operation and returns not-a-number (NaN) if defines a limited precision and exponent range and if - 's absolute value is greater than twice the - sum of the context's EMax property and its Precision - property. - The parameter or is null. - - - Shifts the bits of an arbitrary-precision binary floating - point number's significand. - An arbitrary-precision binary floating point - number containing the significand to shift. - An arbitrary-precision number indicating the - number of bits to shift the first operand's significand. Must be an - integer with an exponent of 0. If this parameter is positive, the - significand is shifted to the left by the given number of bits. If - this parameter is negative, the significand is shifted to the right - by the given number of bits. - An arithmetic context to control the precision of - arbitrary-precision numbers. Can be null. - An arbitrary-precision binary number whose significand is - shifted the given number of bits. Signals an invalid operation and - returns NaN (not-a-number) if is a signaling - NaN or if is not an integer, is negative, - has an exponent other than 0, or has an absolute value that exceeds - the maximum precision specified in the context. - The parameter or is null. - - - Rotates the bits of an arbitrary-precision binary number's - significand. - An arbitrary-precision number containing the - significand to rotate. If this significand contains more bits than - the precision, the most-significant bits are chopped off the - significand. - An arbitrary-precision number indicating the - number of bits to rotate the first operand's significand. Must be - an integer with an exponent of 0. If this parameter is positive, - the significand is shifted to the left by the given number of bits - and the most-significant bits shifted out of the significand become - the least-significant bits instead. If this parameter is negative, - the number is shifted by the given number of bits and the - least-significant bits shifted out of the significand become the - most-significant bits instead. - An arithmetic context to control the precision of - arbitrary-precision numbers. If this parameter is null or specifies - an unlimited precision, this method has the same behavior as - Shift. - An arbitrary-precision binary number whose significand is - rotated the given number of bits. Signals an invalid operation and - returns NaN (not-a-number) if is a signaling - NaN or if is not an integer, is negative, - has an exponent other than 0, or has an absolute value that exceeds - the maximum precision specified in the context. - The parameter or is null. - - - Compares the values of one arbitrary-precision number - object and another object, imposing a total ordering on all - possible values. In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - The first arbitrary-precision number to - compare. - The second arbitrary-precision number to - compare. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects are null or equal, or -1 if - the first object is null or less than the other object, or 1 if the - first object is greater or the other object is null. Does not - signal flags if either value is signaling NaN. - - - Compares the absolute values of two arbitrary-precision - number objects, imposing a total ordering on all possible values - (ignoring their signs). In this method: - - For objects with the same value, the one with the higher - exponent has a greater "absolute value". - Negative zero and positive zero are considered equal. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - The first arbitrary-precision number to - compare. - The second arbitrary-precision number to - compare. - An arithmetic context. Flags will be set in this - context only if HasFlags and IsSimplified of the - context are true and only if an operand needed to be rounded before - carrying out the operation. Can be null. - The number 0 if both objects are null or equal (ignoring - their signs), or -1 if the first object is null or less than the - other object (ignoring their signs), or 1 if the first object is - greater (ignoring their signs) or the other object is null. Does - not signal flags if either value is signaling NaN. - - - Creates a copy of the given arbitrary-precision number - object. - An arbitrary-precision number object to - copy. - A copy of the given arbitrary-precision number - object. - The parameter is null. - - - Returns a canonical version of the given - arbitrary-precision number object. In this method, this method - behaves like the Copy method. - An arbitrary-precision number object. - A copy of the parameter . - - - Returns an arbitrary-precision number object with the same - value as the given number object but with a nonnegative sign (that - is, the given number object's absolute value). - An arbitrary-precision number object. - An arbitrary-precision number object with the same value - as the given number object but with a nonnegative sign. - The parameter is null. - - - Returns an arbitrary-precision number object with the sign - reversed from the given number object. - An arbitrary-precision number object. - An arbitrary-precision number object with the sign - reversed from the given number object. - The parameter is null. - - - Returns an arbitrary-precision number object with the same - value as the first given number object but with a the same sign - (positive or negative) as the second given number object. - An arbitrary-precision number object with the - value the result will have. - The parameter is an - arbitrary-precision binary floating-point number. - An arbitrary-precision number object with the same value - as the first given number object but with a the same sign (positive - or negative) as the second given number object. - The parameter or is null. - - - Returns whether two arbitrary-precision numbers have the - same exponent, they both are not-a-number (NaN), or they both are - infinity (positive and/or negative). - The first arbitrary-precision number. - The second arbitrary-precision number. - Either true if the given arbitrary-precision - numbers have the same exponent, they both are not-a-number (NaN), - or they both are infinity (positive and/or negative); otherwise, - false. - - - Returns an arbitrary-precision number with the same value - as this one but with certain trailing zeros removed from its - significand. If the number's exponent is 0, it is returned - unchanged (but may be rounded depending on the arithmetic context); - if that exponent is greater 0, its trailing zeros are removed from - the significand (then rounded if necessary); if that exponent is - less than 0, its trailing zeros are removed from the significand - until the exponent reaches 0 (then the number is rounded if - necessary). - An arbitrary-precision number. - An arithmetic context to control the precision, - rounding, and exponent range of the result. Can be null. - An arbitrary-precision number with the same value as this - one but with certain trailing zeros removed from its significand. - If is not-a-number (NaN) or infinity, it is - generally returned unchanged. - - - Returns an arbitrary-precision binary number with the same - value as this object but with the given exponent, expressed as an - arbitrary-precision binary number. - Note that this is not always the same as rounding to a given - number of binary places, since it can fail if the difference - between this value's exponent and the desired exponent is too big, - depending on the maximum precision. If rounding to a number of - binary places is desired, it's better to use the RoundToExponent - and RoundToIntegral methods instead. - Remark: This method can be used to implement - fixed-point binary arithmetic, in which a fixed number of digits - come after the binary point. A fixed-point binary arithmetic in - which no digits come after the binary point (a desired exponent of - 0) is considered an "integer arithmetic" . - An arbitrary-precision binary number whose - exponent is to be changed. - The desired exponent of the result, expressed - as an arbitrary-precision binary number. The exponent is the number - of fractional digits in the result, expressed as a negative number. - Can also be positive, which eliminates lower-order places from the - number. For example, -3 means round to the sixteenth (10b^-3, - 0.0001b), and 3 means round to the sixteens-place (10b^3, 1000b). A - value of 0 rounds the number to an integer. - An arithmetic context to control precision and - rounding of the result. If HasFlags of the context is true, - will also store the flags resulting from the operation (the flags - are in addition to the pre-existing flags). Can be null, in which - case the default rounding mode is HalfEven. - An arbitrary-precision binary number with the same value - as this object but with the exponent changed. Signals FlagInvalid - and returns not-a-number (NaN) if the result can't fit the given - precision without rounding, or if the arithmetic context defines an - exponent range and the given exponent is outside that - range. - - - Performs a logical AND operation on two binary numbers in - the form of - logical operands. A logical operand is a - non-negative base-2 number with an Exponent property of 0 (examples - include the base-2 numbers 01001 and 111001 ). The - logical AND operation sets each bit of the result to 1 if the - corresponding bits of each logical operand are both 1, and to 0 - otherwise. For example, 01001 AND 111010=01000. - The first logical operand to the logical AND - operation. - The second logical operand to the logical AND - operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more bits than the maximum precision - specified in this context, the operand's most significant bits that - exceed that precision are discarded. This parameter can be - null. - The result of the logical AND operation as a logical - operand. Signals an invalid operation and returns not-a-number - (NaN) if , , or both - are not logical operands. - - - Performs a logical NOT operation on a binary number in the - form of a - logical operand. A logical operand is a non-negative - base-2 number with an Exponent property of 0 (examples include - 01001 and 111001 ). The logical NOT operation sets - each bit of the result to 1 if the corresponding bit is 0, and to 0 - otherwise; it can set no more bits than the maximum precision, - however. For example, if the maximum precision is 8 bits, then - NOT 111010=11000101. - The operand to the logical NOT operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more bits than the maximum precision - specified in this context, the operand's most significant bits that - exceed that precision are discarded. This parameter cannot be null - and must specify a maximum precision (unlimited precision contexts - are not allowed). - The result of the logical NOT operation as a logical - operand. Signals an invalid operation and returns not-a-number - (NaN) if is not a logical operand. - - - Performs a logical exclusive-OR (XOR) operation on two - binary numbers in the form of - logical operands. A logical operand is a - non-negative base-2 number with an Exponent property of 0 (examples - include the base-2 numbers 01001 and 111001 ). The - logical exclusive-OR operation sets each digit of the result to 1 - if either corresponding digit of the logical operands, but not - both, is 1, and to 0 otherwise. For example, 01001 XOR 111010 = - 101010. - The first logical operand to the logical - exclusive-OR operation. - The second logical operand to the logical - exclusive-OR operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more bits than the maximum precision - specified in this context, the operand's most significant bits that - exceed that precision are discarded. This parameter can be - null. - The result of the logical exclusive-OR operation as a - logical operand. Signals an invalid operation and returns - not-a-number (NaN) if , , or both are not logical operands. - - - Performs a logical OR operation on two binary numbers in - the form of - logical operands. A logical operand is a - non-negative base-2 number with an Exponent property of 0 (examples - include the base-2 numbers 01001 and 111001 ). The - logical OR operation sets each bit of the result to 1 if either or - both of the corresponding bits of each logical operand are 1, and - to 0 otherwise. For example, 01001 OR 111010=111011. - The first logical operand to the logical OR - operation. - The second logical operand to the logical OR - operation. - An arithmetic context to control the maximum - precision of arbitrary-precision numbers. If a logical operand - passed to this method has more bits than the maximum precision - specified in this context, the operand's most significant bits that - exceed that precision are discarded. This parameter can be - null. - The result of the logical OR operation as a logical - operand. Signals an invalid operation and returns not-a-number - (NaN) if , , or both - are not logical operands. - - - Represents an arbitrary-precision integer. (The "E" stands - for "extended", and has this prefix to group it with the other - classes common to this library, particularly EDecimal, EFloat, and - ERational.) - Instances of this class are immutable, so they are inherently - safe for use by multiple threads. Multiple instances of this object - with the same value are interchangeable, but they should be - compared using the "Equals" method rather than the "==" - operator. - Security note - It is not recommended to implement security-sensitive - algorithms using the methods in this class, for several - reasons: - - EInteger objects are immutable, so they can't be - modified, and the memory they occupy is not guaranteed to be - cleared in a timely fashion due to garbage collection. This is - relevant for applications that use many-bit-long numbers as secret - parameters. - The methods in this class (especially those that involve - arithmetic) are not guaranteed to be "constant-time" - (non-data-dependent) for all relevant inputs. Certain attacks that - involve encrypted communications have exploited the timing and - other aspects of such communications to derive keying material or - cleartext indirectly. - Applications should instead use dedicated security libraries - to handle big numbers in security-sensitive - algorithms. - - - Gets the number 1 as an arbitrary-precision - integer. - The number 1 as an arbitrary-precision integer. - - - Gets the number 10 as an arbitrary-precision - integer. - The number 10 as an arbitrary-precision integer. - - - Gets the number zero as an arbitrary-precision - integer. - The number zero as an arbitrary-precision integer. - - - Gets a value indicating whether this value is - even. - true if this value is even; otherwise, false. - - - Gets a value indicating whether this object's value is a - power of two, and greater than 0. - true if this object's value is a power of two, and - greater than 0; otherwise, false. - - - Gets a value indicating whether this value is 0. - true if this value is 0; otherwise, false. - - - Gets the sign of this object's value. - The sign of this object's value. - - - Initializes an arbitrary-precision integer from an array - of bytes. - A byte array consisting of the two's-complement - form (see - "Forms of numbers" ) of - the arbitrary-precision integer to create. The byte array is - encoded using the rules given in the FromBytes(bytes, offset, - length, littleEndian) overload. - If true, the byte order is - little-endian, or least-significant-byte first. If false, the byte - order is big-endian, or most-significant-byte first. - An arbitrary-precision integer. Returns 0 if the byte - array's length is 0. - The parameter is null. - - - Initializes an arbitrary-precision integer from a portion - of an array of bytes. The portion of the byte array is encoded - using the following rules: - - Positive numbers have the first byte's highest bit cleared, - and negative numbers have the bit set. - The last byte contains the lowest 8-bits, the next-to-last - contains the next lowest 8 bits, and so on. For example, the number - 300 can be encoded as 0x01, 0x2C and 200 as 0x00, - 0xC8. (Note that the second example contains a set high bit in - 0xC8, so an additional 0 is added at the start to ensure - it's interpreted as positive.) - To encode negative numbers, take the absolute value of the - number, subtract by 1, encode the number into bytes, and toggle - each bit of each byte. Any further bits that appear beyond the most - significant bit of the number will be all ones. For example, the - number -450 can be encoded as 0xfe, 0x70 and -52869 as - 0xff, 0x31, 0x7B. (Note that the second example contains a - cleared high bit in 0x31, 0x7B, so an additional 0xff is - added at the start to ensure it's interpreted as - negative.) - For little-endian, the byte order is reversed from the byte - order just discussed. - A byte array consisting of the two's-complement - form (see - "Forms of numbers" ) of - the arbitrary-precision integer to create. The byte array is - encoded using the rules given in the FromBytes(bytes, offset, - length, littleEndian) overload. - An index starting at 0 showing where the - desired portion of begins. - The length, in bytes, of the desired portion - of (but not more than 's length). - If true, the byte order is - little-endian, or least-significant-byte first. If false, the byte - order is big-endian, or most-significant-byte first. - An arbitrary-precision integer. Returns 0 if the byte - array's length is 0. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Converts a boolean value (true or false) to an - arbitrary-precision integer. - Either true or false. - The number 1 if is true; - otherwise, 0. - - - Converts a 32-bit signed integer to an arbitrary-precision - integer. - The parameter is - a 32-bit signed integer. - An arbitrary-precision integer with the same value as the - 64-bit number. - - - Converts an unsigned integer expressed as a 64-bit signed - integer to an arbitrary-precision integer. - A 64-bit signed integer. If this value is - 0 or greater, the return value will represent it. If this value is - less than 0, the return value will store 2^64 plus this value - instead. - An arbitrary-precision integer. If is 0 or greater, the return value will - represent it. If is less than 0, the - return value will store 2^64 plus this value instead. - - - Converts a 64-bit signed integer to an arbitrary-precision - integer. - The parameter is a 64-bit signed integer. - An arbitrary-precision integer with the same value as the - 64-bit number. - - - Converts a string to an arbitrary-precision integer in a - given radix. - A string described by the FromRadixSubstring - method. - A base from 2 to 36. Depending on the radix, - the string can use the basic digits 0 to 9 (U+0030 to U+0039) and - then the basic upper-case letters A to Z (U+0041 to U+005A). For - example, 0-9 in radix 10, and 0-9, then A-F in radix 16. Where a - basic upper-case letter A to Z is allowed in the string, the - corresponding basic lower-case letter (U+0061 to U+007a) is allowed - instead. - An arbitrary-precision integer with the same value as the - given string. - The parameter is null. - The string is empty or in an - invalid format. - - - Converts a portion of a string to an arbitrary-precision - integer in a given radix. - A text string. The desired portion of the string - must contain only characters allowed by the given radix, except - that it may start with a minus sign ("-", U+002D) to indicate a - negative number. The desired portion is not allowed to contain - white space characters, including spaces. The desired portion may - start with any number of zeros. - A base from 2 to 36. Depending on the radix, - the string can use the basic digits 0 to 9 (U+0030 to U+0039) and - then the basic upper-case letters A to Z (U+0041 to U+005A). For - example, 0-9 in radix 10, and 0-9, then A-F in radix 16. Where a - basic upper-case letter A to Z is allowed in the string, the - corresponding basic lower-case letter (U+0061 to U+007a) is allowed - instead. - The index of the string that starts the string - portion. - The index of the string that ends the string - portion. The length will be index + endIndex - 1. - An arbitrary-precision integer with the same value as - given in the string portion. - The parameter is null. - The string portion is empty or in - an invalid format. - - - Converts a portion of a sequence of char s to an - arbitrary-precision integer. - A sequence of char s, the desired portion - of which describes an integer in base-10 (decimal) form. The - desired portion of the sequence of char s must contain only - basic digits 0 to 9 (U+0030 to U+0039), except that it may start - with a minus sign ("-", U+002D) to indicate a negative number. The - desired portion is not allowed to contain white space characters, - including spaces. The desired portion may start with any number of - zeros. - The index of the sequence of char s that - starts the desired portion. - The index of the sequence of char s - that ends the desired portion. The length will be index + endIndex - - 1. - An arbitrary-precision integer with the same value as - given in the sequence of char s portion. - The parameter is less than 0, is less - than 0, or either is greater than the sequence's length, or - is less than . - The parameter is null. - - - Converts a sequence of char s to an - arbitrary-precision integer. - A sequence of char s describing an integer - in base-10 (decimal) form. The sequence must contain only basic - digits 0 to 9 (U+0030 to U+0039), except that it may start with a - minus sign ("-", U+002D) to indicate a negative number. The - sequence is not allowed to contain white space characters, - including spaces. The sequence may start with any number of - zeros. - An arbitrary-precision integer with the same value as - given in the sequence of char s. - The parameter is in an invalid format. - The parameter is null. - - - Converts a sequence of char s to an - arbitrary-precision integer in a given radix. - A sequence of char s described by the - FromRadixSubstring method. - A base from 2 to 36. Depending on the radix, - the sequence of char s can use the basic digits 0 to 9 - (U+0030 to U+0039) and then the basic upper-case letters A to Z - (U+0041 to U+005A). For example, 0-9 in radix 10, and 0-9, then A-F - in radix 16. Where a basic upper-case letter A to Z is allowed in - the sequence of char s, the corresponding basic lower-case - letter (U+0061 to U+007a) is allowed instead. - An arbitrary-precision integer with the same value as the - given sequence of char s. - The parameter is null. - The sequence of char s is - empty or in an invalid format. - - - Converts a portion of a sequence of char s to an - arbitrary-precision integer in a given radix. - A text sequence of char s. The desired - portion of the sequence of char s must contain only - characters allowed by the given radix, except that it may start - with a minus sign ("-", U+002D) to indicate a negative number. The - desired portion is not allowed to contain white space characters, - including spaces. The desired portion may start with any number of - zeros. - A base from 2 to 36. Depending on the radix, - the sequence of char s can use the basic digits 0 to 9 - (U+0030 to U+0039) and then the basic upper-case letters A to Z - (U+0041 to U+005A). For example, 0-9 in radix 10, and 0-9, then A-F - in radix 16. Where a basic upper-case letter A to Z is allowed in - the sequence of char s, the corresponding basic lower-case - letter (U+0061 to U+007a) is allowed instead. - The index of the sequence of char s that - starts the desired portion. - The index of the sequence of char s - that ends the desired portion. The length will be index + endIndex - - 1. - An arbitrary-precision integer with the same value as - given in the sequence's portion. - The parameter is null. - The portion is empty or in an - invalid format. - - - Converts a portion of a sequence of bytes (interpreted as - text) to an arbitrary-precision integer. Each byte in the sequence - has to be a character in the Basic Latin range (0x00 to 0x7f or - U+0000 to U+007F) of the Unicode Standard. - A sequence of bytes (interpreted as text), the - desired portion of which describes an integer in base-10 (decimal) - form. The desired portion of the sequence of bytes (interpreted as - text) must contain only basic digits 0 to 9 (U+0030 to U+0039), - except that it may start with a minus sign ("-", U+002D) to - indicate a negative number. The desired portion is not allowed to - contain white space characters, including spaces. The desired - portion may start with any number of zeros. - The index of the sequence of bytes (interpreted - as text) that starts the desired portion. - The index of the sequence of bytes - (interpreted as text) that ends the desired portion. The length - will be index + endIndex - 1. - An arbitrary-precision integer with the same value as - given in the sequence of bytes (interpreted as text) - portion. - The parameter is less than 0, is less - than 0, or either is greater than the sequence's length, or - is less than . - The parameter is null. - - - Converts a sequence of bytes (interpreted as text) to an - arbitrary-precision integer. Each byte in the sequence has to be a - code point in the Basic Latin range (0x00 to 0x7f or U+0000 to - U+007F) of the Unicode Standard. - A sequence of bytes describing an integer in - base-10 (decimal) form. The sequence must contain only basic digits - 0 to 9 (U+0030 to U+0039), except that it may start with a minus - sign ("-", U+002D) to indicate a negative number. The sequence is - not allowed to contain white space characters, including spaces. - The sequence may start with any number of zeros. - An arbitrary-precision integer with the same value as - given in the sequence of bytes. - The parameter is in an invalid format. - The parameter is null. - - - Converts a sequence of bytes (interpreted as text) to an - arbitrary-precision integer in a given radix. Each byte in the - sequence has to be a character in the Basic Latin range (0x00 to - 0x7f or U+0000 to U+007F) of the Unicode Standard. - A sequence of bytes (interpreted as text) - described by the FromRadixSubstring method. - A base from 2 to 36. Depending on the radix, - the sequence of bytes can use the basic digits 0 to 9 (U+0030 to - U+0039) and then the basic upper-case letters A to Z (U+0041 to - U+005A). For example, 0-9 in radix 10, and 0-9, then A-F in radix - 16. Where a basic upper-case letter A to Z is allowed in the - sequence of bytes, the corresponding basic lower-case letter - (U+0061 to U+007a) is allowed instead. - An arbitrary-precision integer with the same value as the - given sequence of bytes. - The parameter is null. - The sequence of bytes - (interpreted as text) is empty or in an invalid format. - - - Converts a portion of a sequence of bytes (interpreted as - text) to an arbitrary-precision integer in a given radix. Each byte - in the sequence has to be a character in the Basic Latin range - (0x00 to 0x7f or U+0000 to U+007F) of the Unicode - Standard. - A sequence of bytes (interpreted as text). The - desired portion of the sequence of bytes (interpreted as text) must - contain only characters allowed by the given radix, except that it - may start with a minus sign ("-", U+002D) to indicate a negative - number. The desired portion is not allowed to contain white space - characters, including spaces. The desired portion may start with - any number of zeros. - A base from 2 to 36. Depending on the radix, - the sequence of bytes (interpreted as text) can use the basic - digits 0 to 9 (U+0030 to U+0039) and then the basic upper-case - letters A to Z (U+0041 to U+005A). For example, 0-9 in radix 10, - and 0-9, then A-F in radix 16. Where a basic upper-case letter A to - Z is allowed in the sequence of bytes (interpreted as text), the - corresponding basic lower-case letter (U+0061 to U+007a) is allowed - instead. - The index of the sequence of bytes (interpreted - as text) that starts the desired portion. - The index of the sequence of bytes - (interpreted as text) that ends the desired portion. The length - will be index + endIndex - 1. - An arbitrary-precision integer with the same value as - given in the sequence's portion. - The parameter is null. - The portion is empty or in an - invalid format. - - - Converts a string to an arbitrary-precision - integer. - A text string describing an integer in base-10 - (decimal) form. The string must contain only basic digits 0 to 9 - (U+0030 to U+0039), except that it may start with a minus sign - ("-", U+002D) to indicate a negative number. The string is not - allowed to contain white space characters, including spaces. The - string may start with any number of zeros. - An arbitrary-precision integer with the same value as - given in the string. - The parameter is in an invalid format. - The parameter is null. - - - Converts a portion of a string to an arbitrary-precision - integer. - A text string, the desired portion of which - describes an integer in base-10 (decimal) form. The desired portion - of the string must contain only basic digits 0 to 9 (U+0030 to - U+0039), except that it may start with a minus sign ("-", U+002D) - to indicate a negative number. The desired portion is not allowed - to contain white space characters, including spaces. The desired - portion may start with any number of zeros. - The index of the string that starts the string - portion. - The index of the string that ends the string - portion. The length will be index + endIndex - 1. - An arbitrary-precision integer with the same value as - given in the string portion. - The parameter is less than 0, is less - than 0, or either is greater than the string's length, or is less than . - The parameter is null. - - - Returns the absolute value of this object's - value. - This object's value with the sign removed. - - - Adds this arbitrary-precision integer and another - arbitrary-precision integer and returns the result. - Another arbitrary-precision - integer. - The sum of the two numbers, that is, this - arbitrary-precision integer plus another arbitrary-precision - integer. - The parameter is null. - - - Converts this object's value to a 32-bit signed integer, - throwing an exception if it can't fit. - A 32-bit signed integer. - This object's value - is too big to fit a 32-bit signed integer. - - - Converts this object's value to a 32-bit signed integer. - If the value can't fit in a 32-bit integer, returns the lower 32 - bits of this object's two's-complement form (see - "Forms of numbers" ) (in - which case the return value might have a different sign than this - object's value). - A 32-bit signed integer. - - - Converts this object's value to a 64-bit signed integer, - throwing an exception if it can't fit. - A 64-bit signed integer. - This object's value - is too big to fit a 64-bit signed integer. - - - Converts this object's value to a 64-bit signed integer. - If the value can't fit in a 64-bit integer, returns the lower 64 - bits of this object's two's-complement form (see - "Forms of numbers" ) (in - which case the return value might have a different sign than this - object's value). - A 64-bit signed integer. - - - Returns whether this object's value can fit in a 32-bit - signed integer. - true if this object's value is from -2147483648 - through 2147483647; otherwise, false. - - - Returns whether this object's value can fit in a 64-bit - signed integer. - true if this object's value is from - -9223372036854775808 through 9223372036854775807; otherwise, - false. - - - Compares an arbitrary-precision integer with this - instance. - The integer to compare to this value. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is greater. - This implementation returns a positive number if 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.. - - - Returns the greater of two arbitrary-precision - integers. - The first integer to compare. - The second integer to compare. - The greater of the two integers. - The parameter or is null. - - - Returns the smaller of two arbitrary-precision - integers. - The first integer to compare. - The second integer to compare. - The smaller of the two integers. - The parameter or is null. - - - Of two arbitrary-precision integers, returns the one with - the greater absolute value. If both integers have the same absolute - value, this method has the same effect as Max. - The first integer to compare. - The second integer to compare. - The integer with the greater absolute value. - The parameter or is null. - - - Of two arbitrary-precision integers, returns the one with - the smaller absolute value. If both integers have the same absolute - value, this method has the same effect as Min. - The first integer to compare. - The second integer to compare. - The integer with the smaller absolute value. - The parameter or is null. - - - Adds this arbitrary-precision integer and a 32-bit signed - integer and returns the result. - The parameter is - a 32-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision integer plus a 32-bit signed integer. - - - Subtracts a 32-bit signed integer from this - arbitrary-precision integer and returns the result. - The parameter is - a 32-bit signed integer. - The difference between the two numbers, that is, this - arbitrary-precision integer minus a 32-bit signed - integer. - - - Multiplies this arbitrary-precision integer by a 32-bit - signed integer and returns the result. - The parameter is - a 32-bit signed integer. - The product of the two numbers, that is, this - arbitrary-precision integer times a 32-bit signed - integer. - - EInteger result = EInteger.FromString("5").Multiply(200); - . - - - - Divides this arbitrary-precision integer by a 32-bit - signed integer and returns the result. The result of the division - is rounded down (the fractional part is discarded). Except if the - result of the division is 0, it will be negative if this - arbitrary-precision integer is positive and the other 32-bit signed - integer is negative, or vice versa, and will be positive if both - are positive or both are negative. - The divisor. - The result of dividing this arbitrary-precision integer by - a 32-bit signed integer. The result of the division is rounded down - (the fractional part is discarded). Except if the result of the - division is 0, it will be negative if this arbitrary-precision - integer is positive and the other 32-bit signed integer is - negative, or vice versa, and will be positive if both are positive - or both are negative. - Attempted to divide by - zero. - - - Returns the remainder that would result when this - arbitrary-precision integer is divided by a 32-bit signed integer. - The remainder is the number that remains when the absolute value of - this arbitrary-precision integer is divided by the absolute value - of the other 32-bit signed integer; the remainder has the same sign - (positive or negative) as this arbitrary-precision - integer. - The parameter is - a 32-bit signed integer. - The remainder that would result when this - arbitrary-precision integer is divided by a 32-bit signed - integer. - Attempted to divide by - zero. - The parameter is null. - - - Compares an arbitrary-precision integer with this - instance. - The parameter is - a 32-bit signed integer. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is - greater. - - - Divides this arbitrary-precision integer by another - arbitrary-precision integer and returns the result. The result of - the division is rounded down (the fractional part is discarded). - Except if the result of the division is 0, it will be negative if - this arbitrary-precision integer is positive and the other - arbitrary-precision integer is negative, or vice versa, and will be - positive if both are positive or both are negative. - The divisor. - The result of dividing this arbitrary-precision integer by - another arbitrary-precision integer. The result of the division is - rounded down (the fractional part is discarded). Except if the - result of the division is 0, it will be negative if this - arbitrary-precision integer is positive and the other - arbitrary-precision integer is negative, or vice versa, and will be - positive if both are positive or both are negative. - The parameter is null. - Attempted to divide by - zero. - - - Divides this arbitrary-precision integer by a 32-bit - signed integer and returns a two-item array containing the result - of the division and the remainder, in that order. The result of the - division is rounded down (the fractional part is discarded). Except - if the result of the division is 0, it will be negative if this - arbitrary-precision integer is positive and the other 32-bit signed - integer is negative, or vice versa, and will be positive if both - are positive or both are negative. The remainder is the number that - remains when the absolute value of this arbitrary-precision integer - is divided by the absolute value of the other 32-bit signed - integer; the remainder has the same sign (positive or negative) as - this arbitrary-precision integer. - The number to divide by. - An array of two items: the first is the result of the - division as an arbitrary-precision integer, and the second is the - remainder as an arbitrary-precision integer. The result of division - is the result of the Divide method on the two operands, and the - remainder is the result of the Remainder method on the two - operands. - The parameter is 0. - - - Adds this arbitrary-precision integer and a 64-bit signed - integer and returns the result. - The parameter - is a 64-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision integer plus a 64-bit signed integer. - - - Subtracts a 64-bit signed integer from this - arbitrary-precision integer and returns the result. - The parameter - is a 64-bit signed integer. - The difference between the two numbers, that is, this - arbitrary-precision integer minus a 64-bit signed - integer. - - - Multiplies this arbitrary-precision integer by a 64-bit - signed integer and returns the result. - The parameter - is a 64-bit signed integer. - The product of the two numbers, that is, this - arbitrary-precision integer times a 64-bit signed - integer. - - - Divides this arbitrary-precision integer by a 64-bit - signed integer and returns the result. The result of the division - is rounded down (the fractional part is discarded). Except if the - result of the division is 0, it will be negative if this - arbitrary-precision integer is positive and the other 64-bit signed - integer is negative, or vice versa, and will be positive if both - are positive or both are negative. - The parameter - is a 64-bit signed integer. - The result of dividing this arbitrary-precision integer by - a 64-bit signed integer. The result of the division is rounded down - (the fractional part is discarded). Except if the result of the - division is 0, it will be negative if this arbitrary-precision - integer is positive and the other 64-bit signed integer is - negative, or vice versa, and will be positive if both are positive - or both are negative. - - - Returns the remainder that would result when this - arbitrary-precision integer is divided by a 64-bit signed integer. - The remainder is the number that remains when the absolute value of - this arbitrary-precision integer is divided by the absolute value - of the other 64-bit signed integer; the remainder has the same sign - (positive or negative) as this arbitrary-precision - integer. - The parameter - is a 64-bit signed integer. - The remainder that would result when this - arbitrary-precision integer is divided by a 64-bit signed - integer. - - - Compares an arbitrary-precision integer with this - instance. - The parameter - is a 64-bit signed integer. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is - greater. - - - Divides this arbitrary-precision integer by a 64-bit - signed integer and returns a two-item array containing the result - of the division and the remainder, in that order. The result of the - division is rounded down (the fractional part is discarded). Except - if the result of the division is 0, it will be negative if this - arbitrary-precision integer is positive and the other 64-bit signed - integer is negative, or vice versa, and will be positive if both - are positive or both are negative. The remainder is the number that - remains when the absolute value of this arbitrary-precision integer - is divided by the absolute value of the other 64-bit signed - integer; the remainder has the same sign (positive or negative) as - this arbitrary-precision integer. - The parameter is a 64-bit signed integer. - An array of two items: the first is the result of the - division as an arbitrary-precision integer, and the second is the - remainder as an arbitrary-precision integer. The result of division - is the result of the Divide method on the two operands, and the - remainder is the result of the Remainder method on the two - operands. - - - Divides this arbitrary-precision integer by another - arbitrary-precision integer and returns a two-item array containing - the result of the division and the remainder, in that order. The - result of the division is rounded down (the fractional part is - discarded). Except if the result of the division is 0, it will be - negative if this arbitrary-precision integer is positive and the - other arbitrary-precision integer is negative, or vice versa, and - will be positive if both are positive or both are negative. The - remainder is the number that remains when the absolute value of - this arbitrary-precision integer is divided by the absolute value - of the other arbitrary-precision integer; the remainder has the - same sign (positive or negative) as this arbitrary-precision - integer. - The number to divide by. - An array of two items: the first is the result of the - division as an arbitrary-precision integer, and the second is the - remainder as an arbitrary-precision integer. The result of division - is the result of the Divide method on the two operands, and the - remainder is the result of the Remainder method on the two - operands. - The parameter is 0. - The parameter is null. - - - Determines whether this object and another object are - equal and have the same type. - The parameter is an - arbitrary object. - true if this object and another object are equal; - otherwise, false. - - - Returns the greatest common divisor of this integer and - the given integer. The greatest common divisor (GCD) is also known - as the greatest common factor (GCF). This method works even if - either or both integers are negative. - Another arbitrary-precision integer. Can - be negative. - The greatest common divisor of this integer and the given - integer. - The parameter is null. - Attempted to divide by - zero. - BigPower is - negative. - - - Returns the number of decimal digits used by this integer, - in the form of an arbitrary-precision integer. - The number of digits in the decimal form of this integer. - Returns 1 if this number is 0. - - - Returns the number of decimal digits used by this - integer. - The number of digits in the decimal form of this integer. - Returns 1 if this number is 0. - The return value would exceed - the range of a 32-bit signed integer. - - - Returns the number of decimal digits used by this integer, - in the form of a 64-bit signed integer. - The number of digits in the decimal form of this integer. - Returns 1 if this number is 0. Returns 2^63 - 1( - Int64.MaxValue in.NET or Long.MAX_VALUE in Java) if - the number of decimal digits is 2^63 - 1 or greater. (Use - GetDigitCountAsEInteger instead if the application relies on - the exact number of decimal digits.). - - - Returns the hash code for this instance. No application or - process IDs are used in the hash code calculation. - A 32-bit signed integer. - - - Gets the bit position of the lowest set bit in this - number's absolute value. (This will also be the position of the - lowest set bit in the number's two's-complement form (see - "Forms of numbers" - ).). - The bit position of the lowest bit set in the number's - absolute value, starting at 0. Returns -1 if this value is - 0. - - - Gets the bit position of the lowest set bit in this - number's absolute value, in the form of a 64-bit signed integer. - (This will also be the position of the lowest set bit in the - number's two's-complement form (see - "Forms of numbers" - ).). - The bit position of the lowest bit set in the number's - absolute value, starting at 0. Returns -1 if this value is 0 or - odd. Returns 2^63 - 1 ( Int64.MaxValue in.NET or - Long.MAX_VALUE in Java) if this number is other than zero - but the lowest set bit is at 2^63 - 1 or greater. (Use - GetLowBitAsEInteger instead if the application relies on the - exact value of the lowest set bit position.). - - - Gets the bit position of the lowest set bit in this - number's absolute value, in the form of an arbitrary-precision - integer. (This will also be the position of the lowest set bit in - the number's two's-complement form (see - "Forms of numbers" - ).). - The bit position of the lowest bit set in the number's - absolute value, starting at 0. Returns -1 if this value is 0 or - odd. - - - Returns whether a bit is set in the two's-complement form - (see - "Forms of numbers" ) of - this object's value. - The index, starting at zero, of the bit to - test, where 0 is the least significant bit, 1 is the next least - significant bit, and so on. - true if the given bit is set in the two' - s-complement form (see - "Forms of numbers" ) of - this object's value; otherwise, false. - The parameter is null. - - - Returns whether a bit is set in the two's-complement form - (see - "Forms of numbers" ) of - this object's value. - The index, starting at 0, of the bit to test, - where 0 is the least significant bit, 1 is the next least - significant bit, and so on. - true if the given bit is set in the two' - s-complement form (see - "Forms of numbers" ) of - this object's value; otherwise, false. - - - Finds the minimum number of bits needed to represent this - object's value, except for its sign, and returns that number of - bits as an arbitrary-precision integer. If the value is negative, - finds the number of bits in the value equal to this object's - absolute value minus 1. For example, all integers in the interval - [-(2^63), (2^63) - 1], which is the same as the range of integers - in Java's and.NET's long type, have a signed bit length of - 63 or less, and all other integers have a signed bit length of - greater than 63. - The number of bits in this object's value, except for its - sign. Returns 0 if this object's value is 0 or negative - 1. - - - Finds the minimum number of bits needed to represent this - object's value, except for its sign, and returns that number of - bits as a 64-bit signed integer. If the value is negative, finds - the number of bits in the value equal to this object's absolute - value minus 1. For example, all integers in the interval [-(2^63), - (2^63) - 1], which is the same as the range of integers in Java's - and.NET's long type, have a signed bit length of 63 or less, - and all other integers have a signed bit length of greater than - 63. - The number of bits in this object's value, except for its - sign. Returns 0 if this object's value is 0 or negative 1. If the - return value would be greater than 2^63 - 1 ( Int64.MaxValue - in.NET or Long.MAX_VALUE in Java), returns 2^63 - 1 instead. - (Use GetSignedBitLengthAsEInteger instead of this method if - the application relies on the exact number of bits.). - - - Finds the minimum number of bits needed to represent this - object's value, except for its sign. If the value is negative, - finds the number of bits in the value equal to this object's - absolute value minus 1. For example, all integers in the interval - [-(2^63), (2^63) - 1], which is the same as the range of integers - in Java's and.NET's long type, have a signed bit length of - 63 or less, and all other integers have a signed bit length of - greater than 63. - The number of bits in this object's value, except for its - sign. Returns 0 if this object's value is 0 or negative - 1. - The return value would exceed - the range of a 32-bit signed integer. - - - Returns whether a bit is set in this number's absolute - value. - The index, starting at zero, of the bit to - test, where 0 is the least significant bit, 1 is the next least - significant bit, and so on. - true if the given bit is set in this number's - absolute value. - The parameter is null. - - - Returns whether a bit is set in this number's absolute - value. - The index, starting at 0, of the bit to test, - where 0 is the least significant bit, 1 is the next least - significant bit, and so on. - true if the given bit is set in this number's - absolute value. - - - Finds the minimum number of bits needed to represent this - number's absolute value, and returns that number of bits as an - arbitrary-precision integer. For example, all integers in the - interval [-((2^63) - 1), (2^63) - 1] have an unsigned bit length of - 63 or less, and all other integers have an unsigned bit length of - greater than 63. This interval is not the same as the range of - integers in Java's and.NET's long type. - The number of bits in this object's absolute value. - Returns 0 if this object's value is 0, and returns 1 if the value - is negative 1. - - - Finds the minimum number of bits needed to represent this - number's absolute value, and returns that number of bits as a - 64-bit signed integer. For example, all integers in the interval - [-((2^63) - 1), (2^63) - 1] have an unsigned bit length of 63 or - less, and all other integers have an unsigned bit length of greater - than 63. This interval is not the same as the range of integers in - Java's and.NET's long type. - The number of bits in this object's absolute value. - Returns 0 if this object's value is 0, and returns 1 if the value - is negative 1. If the return value would be greater than 2^63 - 1( - Int64.MaxValue in.NET or Long.MAX_VALUE in Java), - returns 2^63 - 1 instead. (Use - GetUnsignedBitLengthAsEInteger instead of this method if the - application relies on the exact number of bits.). - - - Finds the minimum number of bits needed to represent this - number's absolute value. For example, all integers in the interval - [-((2^63) - 1), (2^63) - 1] have an unsigned bit length of 63 or - less, and all other integers have an unsigned bit length of greater - than 63. This interval is not the same as the range of integers in - Java's and.NET's long type. - The number of bits in this object's absolute value. - Returns 0 if this object's value is 0, and returns 1 if the value - is negative 1. - The return value would exceed - the range of a 32-bit signed integer. - - - Finds the modulus remainder that results when this - instance is divided by the value of an arbitrary-precision integer. - The modulus remainder is the same as the normal remainder if the - normal remainder is positive, and equals divisor plus normal - remainder if the normal remainder is negative. - The number to divide by. - An arbitrary-precision integer. - The parameter is less than 0. - The parameter is null. - - - Finds the modulus remainder that results when this - instance is divided by the value of another integer. The modulus - remainder is the same as the normal remainder if the normal - remainder is positive, and equals divisor plus normal remainder if - the normal remainder is negative. - The divisor of the modulus. - The modulus remainder. - The parameter is less than 0. - - - Calculates the remainder when this arbitrary-precision - integer raised to a certain power is divided by another - arbitrary-precision integer. - The power to raise this integer by. - The integer to divide the raised number - by. - An arbitrary-precision integer. - The parameter or is null. - - - Multiplies this arbitrary-precision integer by another - arbitrary-precision integer and returns the result. - Another arbitrary-precision - integer. - The product of the two numbers, that is, this - arbitrary-precision integer times another arbitrary-precision - integer. - The parameter is null. - - - Gets the value of this object with the sign - reversed. - This object's value with the sign reversed. - - - Raises an arbitrary-precision integer to a - power. - The exponent to raise this integer - to. - The result. Returns 1 if is - 0. - BigPower is - negative. - - - Raises an arbitrary-precision integer to a - power. - The exponent to raise this integer - to. - The result. Returns 1 if is - 0. - The parameter is null. - BigPower is - negative. - - - Raises an arbitrary-precision integer to a - power. - The exponent to raise this integer - to. - The result. Returns 1 if is - 0. - - - Raises an arbitrary-precision integer to a power, which is - given as another arbitrary-precision integer. - The exponent to raise to. - The result. Returns 1 if is - 0. - The parameter is less than 0. - The parameter is null. - - - Returns the remainder that would result when this - arbitrary-precision integer is divided by another - arbitrary-precision integer. The remainder is the number that - remains when the absolute value of this arbitrary-precision integer - is divided by the absolute value of the other arbitrary-precision - integer; the remainder has the same sign (positive or negative) as - this arbitrary-precision integer. - The number to divide by. - The remainder that would result when this - arbitrary-precision integer is divided by another - arbitrary-precision integer. - Attempted to divide by - zero. - The parameter is null. - - - Returns an arbitrary-precision integer with the bits - shifted to the right. For this operation, the arbitrary-precision - integer is treated as a two's-complement form (see - "Forms of numbers" ). - Thus, for negative values, the arbitrary-precision integer is - sign-extended. - The number of bits to shift. Can be negative, - in which case this is the same as ShiftLeft with the absolute value - of this parameter. - An arbitrary-precision integer. - The parameter is null. - - - Returns an arbitrary-precision integer with the bits - shifted to the left by a number of bits given as an - arbitrary-precision integer. A value of 1 doubles this value, a - value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by - 16, and so on. - The number of bits to shift. Can be negative, - in which case this is the same as ShiftRight with the absolute - value of this parameter. - An arbitrary-precision integer. - The parameter is null. - - - Returns an arbitrary-precision integer with the bits - shifted to the left by a number of bits. A value of 1 doubles this - value, a value of 2 multiplies it by 4, a value of 3 by 8, a value - of 4 by 16, and so on. - The number of bits to shift. Can be - negative, in which case this is the same as shiftRight with the - absolute value of this parameter. - An arbitrary-precision integer. - - - Returns an arbitrary-precision integer with every bit - flipped from this one (also called an inversion or NOT - operation). - An arbitrary-precision integer in which each bit in its - two's complement representation is set if the corresponding bit of - this integer is clear, and vice versa. Returns -1 if this integer - is 0. If this integer is positive, the return value is negative, - and vice versa. This method uses the two's complement form of - negative integers (see - "Forms of numbers" ). For - example, in binary, NOT 10100 = ...11101011 (or in decimal, NOT 20 - = -21). In binary, NOT ...11100110 = 11001 (or in decimal, NOT -26 - = 25). - - - Extracts the lowest bits of this integer. This is - equivalent to And(2^longBitCount - 1), but is more - efficient when this integer is non-negative and longBitCount's - value is large. - The number of bits to extract from the - lowest part of this integer. - A value equivalent to And(2^longBitCount - 1). - - - Extracts the lowest bits of this integer. This is - equivalent to And(2^bitCount - 1), but is more efficient - when this integer is non-negative and bitCount's value is - large. - The number of bits to extract from the - lowest part of this integer. - A value equivalent to And(2^bitCount - 1). - - - Extracts the lowest bits of this integer. This is - equivalent to And(2^bigBitCount - 1), but is more efficient - when this integer is non-negative and bigBitCount's value is - large. - The number of bits to extract from the - lowest part of this integer. - A value equivalent to And(2^bigBitCount - 1). - The parameter is null. - - - Does an AND operation between this arbitrary-precision - integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bits of this integer and the other integer (in - their two's-complement representation) are both set. For example, - in binary, 10110 AND 01100 = 00100 (or in decimal, 22 AND 12 = 4). - This method uses the two's complement form of negative integers - (see - "Forms of numbers" ). For - example, in binary, ...11100111 AND 01100 = 00100 (or in decimal, - -25 AND 12 = 4). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an OR operation between this arbitrary-precision - integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit of this integer is set, the other integer's - corresponding bit is set, or both. For example, in binary, 10110 OR - 11010 = 11110 (or in decimal, 22 OR 26 = 30). This method uses the - two's complement form of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101110 OR 01011 = ...11101111 (or in - decimal, -18 OR 11 = -17). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an AND NOT operation between this arbitrary-precision - integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit of this integer is set, and the other - integer's corresponding bit is - not set. For example, in binary, 10110 AND NOT 11010 = 00100 - (or in decimal, 22 AND NOT 26 = 4). This method uses the two's - complement form of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101110 AND NOT 01011 = 00100 (or in - decimal, -18 OR 11 = 4). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an OR NOT operation between this arbitrary-precision - integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit of this integer is set, the other integer's - corresponding bit is - not set, or both. For example, in binary, 10110 OR NOT 11010 - = 00100 (or in decimal, 22 OR NOT 26 = 23). This method uses the - two's complement form of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101110 OR NOT 01011 = ...11111110 (or in - decimal, -18 OR 11 = -2). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an OR NOT operation between this arbitrary-precision - integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit of this integer is set, the other integer's - corresponding bit is - not set, or both. For example, in binary, 10110 OR NOT 11010 - = 00100 (or in decimal, 22 OR NOT 26 = 23). This method uses the - two's complement form of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101110 OR NOT 01011 = ...11111110 (or in - decimal, -18 OR 11 = -2). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an XOR NOT operation (or equivalence operation, EQV - operation, or exclusive-OR NOT operation) between this - arbitrary-precision integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit of this integer is set or the other integer's - corresponding bit is - not set, but not both. For example, in binary, 10110 XOR NOT - 11010 = 10011 (or in decimal, 22 XOR NOT 26 = 19). This method uses - the two's complement form of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101110 XOR NOT 01011 = ...11111010 (or in - decimal, -18 OR 11 = -6). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an XOR NOT operation (or equivalence operation, EQV - operation, or exclusive-OR NOT operation) between this - arbitrary-precision integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit of this integer is set or the other integer's - corresponding bit is - not set, but not both. For example, in binary, 10110 XOR NOT - 11010 = 10011 (or in decimal, 22 XOR NOT 26 = 19). This method uses - the two's complement form of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101110 XOR NOT 01011 = ...11111010 (or in - decimal, -18 OR 11 = -6). - The parameter is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an exclusive OR (XOR) operation between this - arbitrary-precision integer and another one. - Another arbitrary-precision integer that - participates in the operation. - An arbitrary-precision integer in which each bit is set if - the corresponding bit is set in one input integer but not in the - other. For example, in binary, 11010 XOR 01001 = 10011 (or in - decimal, 26 XOR 9 = 19). This method uses the two's complement form - of negative integers (see - "Forms of numbers" ). For - example, in binary, ...11101101 XOR 00011 = ...11101110 (or in - decimal, -19 XOR 3 = -18). - The parameter is null. - - - Returns an arbitrary-precision integer with the bits - shifted to the right. For this operation, the arbitrary-precision - integer is treated as a two's-complement form (see - "Forms of numbers" ). - Thus, for negative values, the arbitrary-precision integer is - sign-extended. - The number of bits to shift. Can be - negative, in which case this is the same as shiftLeft with the - absolute value of this parameter. - An arbitrary-precision integer. - - - Finds the square root of this instance's value, rounded - down. - The square root of this object's value. Returns 0 if this - value is 0 or less. - - - Calculates the square root and the remainder. - An array of two arbitrary-precision integers: the first - integer is the square root, and the second is the difference - between this value and the square of the first integer. Returns two - zeros if this value is 0 or less, or one and zero if this value - equals 1. - - - Finds the nth root of this instance's value, rounded - down. - The root to find; must be 1 or greater. If this - value is 2, this method finds the square root; if 3, the cube root, - and so on. - The square root of this object's value. Returns 0 if this - value is 0 or less. - The parameter is null. - - - Calculates the nth root and the remainder. - The root to find; must be 1 or greater. If this - value is 2, this method finds the square root; if 3, the cube root, - and so on. - An array of two arbitrary-precision integers: the first - integer is the nth root, and the second is the difference between - this value and the nth power of the first integer. Returns two - zeros if this value is 0 or less, or one and zero if this value - equals 1. - The parameter is null. - - - Finds the nth root of this instance's value, rounded - down. - The root to find; must be 1 or greater. If this - value is 2, this method finds the square root; if 3, the cube root, - and so on. - The square root of this object's value. Returns 0 if this - value is 0 or less. - - - Calculates the nth root and the remainder. - The root to find; must be 1 or greater. If this - value is 2, this method finds the square root; if 3, the cube root, - and so on. - An array of two arbitrary-precision integers: the first - integer is the nth root, and the second is the difference between - this value and the nth power of the first integer. Returns two - zeros if this value is 0 or less, or one and zero if this value - equals 1. - - - Subtracts an arbitrary-precision integer from this - arbitrary-precision integer and returns the result. - Another arbitrary-precision - integer. - The difference between the two numbers, that is, this - arbitrary-precision integer minus another arbitrary-precision - integer. - The parameter is null. - - - Returns a byte array of this integer's value. The byte - array will take the number's two's-complement form (see - "Forms of numbers" ), - using the fewest bytes necessary to store its value unambiguously. - If this value is negative, the bits that appear beyond the most - significant bit of the number will be all ones. The resulting byte - array can be passed to the FromBytes() method (with the same - byte order) to reconstruct this integer's value. - See the 'littleEndian' parameter of the - FromBytes() method. - A byte array. If this value is 0, returns a byte array - with the single element 0. - - - Converts this object's value to a 32-bit signed integer, - throwing an exception if it can't fit. - A 32-bit signed integer. - This object's value - is too big to fit a 32-bit signed integer. - - - Converts this object's value to a 32-bit signed integer. - If the value can't fit in a 32-bit integer, returns the lower 32 - bits of this object's two's-complement form (see - "Forms of numbers" ) (in - which case the return value might have a different sign than this - object's value). - A 32-bit signed integer. - - - Converts this object's value to a 64-bit signed integer, - throwing an exception if it can't fit. - A 64-bit signed integer. - This object's value - is too big to fit a 64-bit signed integer. - - - Converts this object's value to a 64-bit signed integer. - If the value can't fit in a 64-bit integer, returns the lower 64 - bits of this object's two's-complement form (see - "Forms of numbers" ) (in - which case the return value might have a different sign than this - object's value). - A 64-bit signed integer. - - - Generates a string representing the value of this object, - in the given radix. - A radix from 2 through 36. For example, to - generate a hexadecimal (base-16) string, specify 16. To generate a - decimal (base-10) string, specify 10. - A string representing the value of this object. If this - value is 0, returns "0". If negative, the string will begin with a - minus sign ("-", U+002D). Depending on the radix, the string will - use the basic digits 0 to 9 (U+0030 to U+0039) and then the basic - upper-case letters A to Z (U+0041 to U+005A). For example, 0-9 in - radix 10, and 0-9, then A-F in radix 16. - - - Converts this object to a text string in base - 10. - A string representation of this object. If this value is - 0, returns "0". If negative, the string will begin with a minus - sign ("-", U+002D). The string will use the basic digits 0 to 9 - (U+0030 to U+0039). - - - Returns one added to this arbitrary-precision - integer. - The given arbitrary-precision integer plus one. - - - Returns one subtracted from this arbitrary-precision - integer. - The given arbitrary-precision integer minus one. - - - Converts this number's value to a byte (from 0 to 255) if - it can fit in a byte (from 0 to 255). - This number's value as a byte (from 0 to 255). - This value is less than 0 or - greater than 255. - - - Converts this number to a byte (from 0 to 255), returning - the least-significant bits of this number's two's-complement - form. - This number, converted to a byte (from 0 to - 255). - - - Converts a byte (from 0 to 255) to an arbitrary-precision - integer. - The number to convert as a byte (from 0 to - 255). - This number's value as an arbitrary-precision - integer. - - - Converts this number's value to a 16-bit signed integer if - it can fit in a 16-bit signed integer. - This number's value as a 16-bit signed integer. - This value is less than -32768 - or greater than 32767. - - - Converts this number to a 16-bit signed integer, returning - the least-significant bits of this number's two's-complement - form. - This number, converted to a 16-bit signed - integer. - - - Converts a 16-bit signed integer to an arbitrary-precision - integer. - The number to convert as a 16-bit signed - integer. - This number's value as an arbitrary-precision - integer. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision integer. - The number to convert as a 64-bit unsigned - integer. - The value of as an - arbitrary-precision integer. - - - Adds an arbitrary-precision integer and another - arbitrary-precision integer and returns the result. - The first operand. - The second operand. - The sum of the two numbers, that is, an - arbitrary-precision integer plus another arbitrary-precision - integer. - The parameter is null. - - - Subtracts two arbitrary-precision integer - values. - An arbitrary-precision integer. - Another arbitrary-precision - integer. - The difference of the two objects. - The parameter is null. - - - Adds one to an arbitrary-precision integer. - An arbitrary-precision integer. - The given arbitrary-precision integer plus one. - The parameter is null. - - - Subtracts one from an arbitrary-precision - integer. - An arbitrary-precision integer. - The given arbitrary-precision integer minus one. - The parameter is null. - - - Multiplies an arbitrary-precision integer by another - arbitrary-precision integer and returns the result. - The first operand. - The second operand. - The product of the two numbers, that is, an - arbitrary-precision integer times another arbitrary-precision - integer. - The parameter is null. - - - Divides an arbitrary-precision integer by the value of an - arbitrary-precision integer object. - The number that will be divided by the - divisor. - The number to divide by. - The quotient of the two objects. - The parameter is null. - - - Returns the remainder that would result when an - arbitrary-precision integer is divided by another - arbitrary-precision integer. The remainder is the number that - remains when the absolute value of an arbitrary-precision integer - is divided by the absolute value of the other arbitrary-precision - integer; the remainder has the same sign (positive or negative) as - this arbitrary-precision integer. - The first operand. - The number to divide by. - The remainder that would result when an - arbitrary-precision integer is divided by another - arbitrary-precision integer. - The parameter is null. - - - Returns an arbitrary-precision integer with the bits - shifted to the left by a number of bits. A value of 1 doubles this - value, a value of 2 multiplies it by 4, a value of 3 by 8, a value - of 4 by 16, and so on. - The arbitrary-precision integer to shift - left. - The number of bits to shift. Can be - negative, in which case this is the same as shiftRight with the - absolute value of this parameter. - An arbitrary-precision integer. - The parameter is null. - - - Calculates the remainder when an arbitrary-precision - integer raised to a certain power is divided by another - arbitrary-precision integer. - The starting operand. - The power to raise this integer by. - The integer to divide the raised number - by. - The value ( ^ )% . - The parameter is null. - - - Shifts the bits of an arbitrary-precision integer to the - right. - Another arbitrary-precision integer. - The parameter is a 32-bit signed integer. - An arbitrary-precision integer. - The parameter is null. - For this operation, the arbitrary-precision integer is - treated as a two's-complement form (see - "Forms of numbers" ). - Thus, for negative values, the arbitrary-precision integer is - sign-extended. - - - Negates an arbitrary-precision integer. - An arbitrary-precision integer to - negate. - An arbitrary-precision integer. - The parameter is null. - - - Converts this number's value to a 64-bit signed integer if - it can fit in a 64-bit signed integer. - This number's value as a 64-bit signed integer. - This value is outside the range - of a 64-bit signed integer. - - - Converts this number to a 64-bit signed integer, returning - the least-significant bits of this number's two's-complement - form. - This number, converted to a 64-bit signed - integer. - - - Determines whether an arbitrary-precision integer is less - than another arbitrary-precision integer. - The first arbitrary-precision - integer. - The second arbitrary-precision - integer. - true if is less than - ; otherwise, false. - - - Determines whether an arbitrary-precision integer is up to - another arbitrary-precision integer. - The first arbitrary-precision - integer. - The second arbitrary-precision - integer. - true if is up to - ; otherwise, false. - - - Determines whether an arbitrary-precision integer is - greater than another arbitrary-precision integer. - The first arbitrary-precision - integer. - The second arbitrary-precision - integer. - true if is greater - than ; otherwise, false. - - - Determines whether an arbitrary-precision integer value is - greater than another arbitrary-precision integer. - The first arbitrary-precision - integer. - The second arbitrary-precision - integer. - true if is at least - ; otherwise, false. - - - Returns an arbitrary-precision integer with every bit - flipped. - The operand as an arbitrary-precision - integer. - An arbitrary-precision integer. - The parameter is null. - - - Does an AND operation between two arbitrary-precision - integer values. For each bit of the result, that bit is 1 if the - corresponding bits of the two operands are both 1, or is 0 - otherwise. - The first operand. - The second operand. - The result of the operation. - The parameter "a" or "b" is - null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an OR operation between two arbitrary-precision - integer instances. For each bit of the result, that bit is 1 if - either or both of the corresponding bits of the two operands are 1, - or is 0 otherwise. - An arbitrary-precision integer. - Another arbitrary-precision - integer. - The result of the operation. - The parameter "first" or - "second" is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Finds the exclusive "or" of two arbitrary-precision - integer objects. For each bit of the result, that bit is 1 if - either of the corresponding bits of the two operands, but not both, - is 1, or is 0 otherwise. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - The first arbitrary-precision integer. - The second arbitrary-precision integer. - An arbitrary-precision integer in which each bit is set if - it's set in one input integer but not the other. - The parameter or is null. - - - Retrieves bits from this integer's two's-complement - form. - Zero-based index of the first bit to retrieve, - where 0 is the least-significant bit of the number. - The number of bits to retrieve, starting - with the first. Must be from 0 through 64. - A 64-bit signed integer containing the bits from this - integer's two's-complement form. The least significant bit is the - first bit, and any unused bits are set to 0. - - - Divides this arbitrary-precision integer by another - arbitrary-precision integer and returns a two-item array containing - the result of the division and the remainder, in that order. The - result of the division is rounded down (the fractional part is - discarded). Except if the result of the division is 0, it will be - negative if this arbitrary-precision integer is positive and the - other arbitrary-precision integer is negative, or vice versa, and - will be positive if both are positive or both are negative. The - remainder is the number that remains when the absolute value of - this arbitrary-precision integer is divided by the absolute value - of the other arbitrary-precision integer; the remainder has the - same sign (positive or negative) as this arbitrary-precision - integer. - The arbitrary-precision integer to be - divided. - The arbitrary-precision integer to divide - by. - An arbitrary-precision integer. - An array of two items: the first is the result of the - division as an arbitrary-precision integer, and the second is the - remainder as an arbitrary-precision integer. The result of division - is the result of the Divide method on the two operands, and the - remainder is the result of the Remainder method on the two - operands. - The parameter or is - null. - - - Determines whether this object and another object are - equal. - Another arbitrary-precision integer. - true if this object and another object are equal; - otherwise, false. - - - Returns an arbitrary-precision integer with every bit - flipped. - The operand as an arbitrary-precision - integer. - An arbitrary-precision integer. - The parameter is null. - - - Does an AND operation between two arbitrary-precision - integer values. - The first arbitrary-precision integer. - The second arbitrary-precision integer. - An arbitrary-precision integer in which each bit is set if - the corresponding bits of the two integers are both set. - The parameter or is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Does an OR operation between two arbitrary-precision - integer instances. - The first operand. - The second operand. - An arbitrary-precision integer. - The parameter or is null. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - - - Finds the exclusive "or" of two arbitrary-precision - integer objects. - Each arbitrary-precision integer is treated as a - two's-complement form (see - "Forms of numbers" ) for - the purposes of this operator. - The first arbitrary-precision integer. - The second arbitrary-precision integer. - An arbitrary-precision integer in which each bit is set if - the corresponding bit is set in one input integer but not in the - other. - The parameter or is null. - - - Converts an arbitrary-precision integer to a byte (from 0 - to 255) if it can fit in a byte (from 0 to 255). - The number to convert as an arbitrary-precision - integer. - The value of as a byte (from 0 to - 255). - The parameter is less than 0 or greater than 255. - The parameter is null. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - integer. - Either true or false. - The value of as an - arbitrary-precision integer. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - integer. - The number to convert as a byte (from 0 to - 255). - The value of as an - arbitrary-precision integer. - - - Converts this number's value to an 8-bit signed integer if - it can fit in an 8-bit signed integer. - This number's value as an 8-bit signed integer. - This value is less than -128 or - greater than 127. - - - Converts this number to an 8-bit signed integer, returning - the least-significant bits of this number's two's-complement - form. - This number, converted to an 8-bit signed - integer. - - - Converts an 8-bit signed integer to an arbitrary-precision - integer. - The number to convert as an 8-bit signed - integer. - This number's value as an arbitrary-precision - integer. - - - Converts an arbitrary-precision integer to an 8-bit signed - integer if it can fit in an 8-bit signed integer. - The number to convert as an arbitrary-precision - integer. - The value of as an 8-bit signed - integer. - The parameter is less than -128 or greater than 127. - The parameter is null. - - - Converts an 8-bit signed integer to an arbitrary-precision - integer. - The number to convert as an 8-bit signed - integer. - The value of as an - arbitrary-precision integer. - - - Converts an arbitrary-precision integer to a 16-bit signed - integer if it can fit in a 16-bit signed integer. - The number to convert as an arbitrary-precision - integer. - The value of as a 16-bit signed - integer. - The parameter is less than -32768 or greater than - 32767. - The parameter is null. - - - Converts a 16-bit signed integer to an arbitrary-precision - integer. - The number to convert as a 16-bit signed - integer. - The value of as an - arbitrary-precision integer. - - - Converts this number's value to a 16-bit unsigned integer - if it can fit in a 16-bit unsigned integer. - This number's value as a 16-bit unsigned - integer. - This value is less than 0 or - greater than 65535. - - - Converts this number to a 16-bit unsigned integer, - returning the least-significant bits of this number's - two's-complement form. - This number, converted to a 16-bit unsigned - integer. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision integer. - The number to convert as a 16-bit - unsigned integer. - This number's value as an arbitrary-precision - integer. - - - Converts an arbitrary-precision integer to a 16-bit - unsigned integer if it can fit in a 16-bit unsigned - integer. - The number to convert as an arbitrary-precision - integer. - The value of as a 16-bit unsigned - integer. - The parameter is less than 0 or greater than 65535. - The parameter is null. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision integer. - The number to convert as a 16-bit - unsigned integer. - The value of as an - arbitrary-precision integer. - - - Converts an arbitrary-precision integer to a 32-bit signed - integer if it can fit in a 32-bit signed integer. - The number to convert as an arbitrary-precision - integer. - The value of as a 32-bit signed - integer. - The parameter is less than -2147483648 or greater than - 2147483647. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - integer. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision integer. - - - Converts this number's value to a 32-bit signed integer if - it can fit in a 32-bit signed integer. - This number's value as a 32-bit signed integer. - This value is less than 0 or - greater than 4294967295. - - - Converts this number to a 32-bit signed integer, returning - the least-significant bits of this number's two's-complement - form. - This number, converted to a 32-bit signed - integer. - - - Converts a 32-bit signed integer to an arbitrary-precision - integer. - The number to convert as a 32-bit signed - integer. - This number's value as an arbitrary-precision - integer. - - - Converts an arbitrary-precision integer to a 32-bit signed - integer if it can fit in a 32-bit signed integer. - The number to convert as an arbitrary-precision - integer. - The value of as a 32-bit signed - integer. - The parameter is less than 0 or greater than - 4294967295. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - integer. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision integer. - - - Converts an arbitrary-precision integer to a 64-bit signed - integer if it can fit in a 64-bit signed integer. - The number to convert as an arbitrary-precision - integer. - The value of as a 64-bit signed - integer. - The parameter is less than -9223372036854775808 or greater than - 9223372036854775807. - The parameter is null. - - - Converts a 64-bit signed integer to an arbitrary-precision - integer. - The number to convert as a 64-bit signed - integer. - The value of as an - arbitrary-precision integer. - - - Converts an arbitrary-precision integer to a 64-bit - unsigned integer if it can fit in a 64-bit unsigned - integer. - The number to convert as an arbitrary-precision - integer. - The value of as a 64-bit unsigned - integer. - The parameter is less than 0 or greater than - 18446744073709551615. - The parameter is null. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision integer. - The number to convert as a 64-bit - unsigned integer. - The value of as an - arbitrary-precision integer. - - - Represents an arbitrary-precision rational number. This - class can't be inherited. (The "E" stands for "extended", meaning - that instances of this class can be values other than numbers - proper, such as infinity and not-a-number.) In this class, a - rational number consists of a numerator and denominator, each an - arbitrary-precision integer (EInteger), and this class does not - automatically convert rational numbers to lowest terms. - Thread safety: Instances of this class are immutable, - so they are inherently safe for use by multiple threads. Multiple - instances of this object with the same properties are - interchangeable, so they should not be compared using the "==" - operator (which might only check if each side of the operator is - the same instance). - - - A not-a-number value. - - - Negative infinity, less than any other number. - - - A rational number for negative zero. - - - The rational number one. - - - Positive infinity, greater than any other - number. - - - A signaling not-a-number value. - - - The rational number ten. - - - A rational number for zero. - - - Initializes a new instance of the - class. - An arbitrary-precision integer serving as - the numerator. - An arbitrary-precision integer serving as - the denominator. - The parameter or is - null. - Denominator is - zero. - - - Creates a copy of this arbitrary-precision rational - number. - An arbitrary-precision rational number. - - - Gets this object's denominator. - This object's denominator. - - - Gets a value indicating whether this object is finite (not - infinity or NaN). - true if this object is finite (not infinity or NaN); - otherwise, false. - - - Gets a value indicating whether this object's value is - negative (including negative zero). - true if this object's value is negative (including - negative zero); otherwise, false. true if this - object's value is negative; otherwise, false. - - - Gets a value indicating whether this object's value equals - 0. - true if this object's value equals 0; otherwise, - false. true if this object's value equals 0; - otherwise, false. - - - Returns whether this object's value is an - integer. - true if this object's value is an integer; - otherwise, false. - - - Gets this object's numerator. - This object's numerator. If this object is a not-a-number - value, returns the diagnostic information (which will be negative - if this object is negative). - - - Gets the sign of this rational number. - The sign of this rational number. - - - Gets this object's numerator with the sign - removed. - This object's numerator. If this object is a not-a-number - value, returns the diagnostic information. - - - Creates a rational number with the given numerator and - denominator. - The numerator. - The denominator. - An arbitrary-precision rational number. - The denominator is - zero. - - - Creates a rational number with the given numerator and - denominator. - The numerator. - The denominator. - An arbitrary-precision rational number. - The denominator is - zero. - - - Creates a rational number with the given numerator and - denominator. - The numerator. - The denominator. - An arbitrary-precision rational number. - The denominator is - zero. - The parameter or is - null. - - - Creates a not-a-number arbitrary-precision rational - number. - An integer, 0 or greater, to use as diagnostic - information associated with this object. If none is needed, should - be zero. To get the diagnostic information from another - arbitrary-precision rational number, use that object's - UnsignedNumerator property. - An arbitrary-precision rational number. - The parameter is less than 0. - - - Creates a not-a-number arbitrary-precision rational - number. - An integer, 0 or greater, to use as diagnostic - information associated with this object. If none is needed, should - be zero. To get the diagnostic information from another - arbitrary-precision rational number, use that object's - UnsignedNumerator property. - Whether the return value will be signaling - (true) or quiet (false). - Whether the return value is - negative. - An arbitrary-precision rational number. - The parameter is less than 0. - The parameter is null. - - - Converts a 64-bit floating-point number to a rational - number. This method computes the exact value of the floating point - number, not an approximation, as is often the case by converting - the number to a string. - The input value can be a not-a-number (NaN) value (such as - Double.NaN ); however, NaN values have multiple forms that - are equivalent for many applications' purposes, and - Double.NaN is only one of these equivalent forms. In fact, - ERational.FromDouble(Double.NaN) could produce an object - that is represented differently between DotNet and Java, because - Double.NaN may have a different form in DotNet and Java (for - example, the NaN value's sign may be negative in DotNet, but - positive in Java). Use `IsNaN()` to determine whether an object - from this class stores a NaN value of any form. - The parameter is a 64-bit - floating-point number. - A rational number with the same value as . - - - Converts an arbitrary-precision decimal number to a - rational number. - The number to convert as an arbitrary-precision - decimal number. - An arbitrary-precision rational number. - - - Converts an arbitrary-precision binary floating-point - number to a rational number. - The number to convert as an arbitrary-precision - binary floating-point number. - An arbitrary-precision rational number. - - - Converts an arbitrary-precision decimal number to a - rational number. - The number to convert as an arbitrary-precision - decimal number. - An arbitrary-precision rational number. - The parameter is null. - doesn't satisfy den.Sign - &gt;= 0. - - - Converts an arbitrary-precision binary floating-point - number to a rational number. - The number to convert as an arbitrary-precision - binary floating-point number. - An arbitrary-precision rational number. - The parameter is null. - - - Converts an arbitrary-precision integer to a rational - number. - The number to convert as an - arbitrary-precision integer. - The exact value of the integer as a rational - number. - - - Converts a 32-bit binary floating-point number to a - rational number. This method computes the exact value of the - floating point number, not an approximation, as is often the case - by converting the number to a string. - The input value can be a not-a-number (NaN) value (such as - Single.NaN in DotNet or Float.NaN in Java); however, NaN - values have multiple forms that are equivalent for many - applications' purposes, and Single.NaN / Float.NaN is - only one of these equivalent forms. In fact, - ERational.FromSingle(Single.NaN) or - ERational.FromSingle(Float.NaN) could produce an object that - is represented differently between DotNet and Java, because - Single.NaN / Float.NaN may have a different form in - DotNet and Java (for example, the NaN value's sign may be negative - in DotNet, but positive in Java). Use `IsNaN()` to determine - whether an object from this class stores a NaN value of any - form. - The parameter is a 32-bit - binary floating-point number. - A rational number with the same value as . - - - Creates a binary rational number from a 32-bit - floating-point number encoded in the IEEE 754 binary32 format. This - method computes the exact value of the floating point number, not - an approximation, as is often the case by converting the number to - a string. - A 32-bit integer encoded in the IEEE 754 - binary32 format. - A rational number with the same floating-point value as - . - - - Creates a binary rational number from a 64-bit - floating-point number encoded in the IEEE 754 binary64 format. This - method computes the exact value of the floating point number, not - an approximation, as is often the case by converting the number to - a string. - A 64-bit integer encoded in the IEEE 754 - binary64 format. - A rational number with the same floating-point value as - . - - - Creates a rational number from a text string that - represents a number. See FromString(String, int, int) for - more information. - A string that represents a number. - An arbitrary-precision rational number with the same value - as the given string. - The parameter is not a correctly formatted number - string. - - - - Creates a rational number from a text string that represents - a number. - The format of the string generally consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if '-' , the value is negative.) - The numerator in the form of one or more digits (these digits - may begin with any number of zeros). - Optionally, "/" followed by the denominator in the form of - one or more digits (these digits may begin with any number of - zeros). If a denominator is not given, it's equal to - 1. - The string can also be "-INF", "-Infinity", "Infinity", - "INF", quiet NaN ("NaN" /"-NaN") followed by any number of digits, - or signaling NaN ("sNaN" /"-sNaN") followed by any number of - digits, all in any combination of upper and lower case. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The string is not - allowed to contain white space characters, including - spaces. - A text string, a portion of which represents a - number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision rational number. - The parameter is not a correctly formatted number - string. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less than - . - - - Creates a rational number from a sequence of char s - that represents a number. See FromString(String, int, int) - for more information. - A sequence of char s that represents a - number. - An arbitrary-precision rational number with the same value - as the given sequence of char s. - The parameter is not a correctly formatted sequence of char - s. - - - - Creates a rational number from a sequence of char s - that represents a number. - The format of the sequence of char s generally - consists of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if '-' , the value is negative.) - The numerator in the form of one or more digits (these digits - may begin with any number of zeros). - Optionally, "/" followed by the denominator in the form of - one or more digits (these digits may begin with any number of - zeros). If a denominator is not given, it's equal to - 1. - The sequence of char s can also be "-INF", - "-Infinity", "Infinity", "INF", quiet NaN ("NaN" /"-NaN") followed - by any number of digits, or signaling NaN ("sNaN" /"-sNaN") - followed by any number of digits, all in any combination of upper - and lower case. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The sequence of - char s is not allowed to contain white space characters, - including spaces. - A sequence of char s, a portion of which - represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision rational number. - The parameter is not a correctly formatted sequence of char - s. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Creates a rational number from a sequence of bytes that - represents a number. See FromString(String, int, int) for - more information. - A sequence of bytes that represents a - number. - An arbitrary-precision rational number with the same value - as the given sequence of bytes. - The parameter is not a correctly formatted sequence of - bytes. - - - - Creates a rational number from a sequence of bytes that - represents a number. - The format of the sequence of bytes generally consists - of: - - An optional plus sign ("+" , U+002B) or minus sign ("-", - U+002D) (if '-' , the value is negative.) - The numerator in the form of one or more digits (these digits - may begin with any number of zeros). - Optionally, "/" followed by the denominator in the form of - one or more digits (these digits may begin with any number of - zeros). If a denominator is not given, it's equal to - 1. - The sequence of bytes can also be "-INF", "-Infinity", - "Infinity", "INF", quiet NaN ("NaN" /"-NaN") followed by any number - of digits, or signaling NaN ("sNaN" /"-sNaN") followed by any - number of digits, all in any combination of upper and lower - case. - All characters mentioned above are the corresponding - characters in the Basic Latin range. In particular, the digits must - be the basic digits 0 to 9 (U+0030 to U+0039). The sequence of - bytes is not allowed to contain white space characters, including - spaces. - A sequence of bytes, a portion of which - represents a number. - An index starting at 0 showing where the - desired portion of begins. - The length, in code units, of the desired - portion of (but not more than 's length). - An arbitrary-precision rational number. - The parameter is not a correctly formatted sequence of - bytes. - The parameter is null. - Either or is less than 0 or - greater than 's length, or 's length minus is less - than . - - - Compares the absolute values of this object and another - object, imposing a total ordering on all possible values (ignoring - their signs). In this method: - - For objects with the same value, the one with the higher - denominator has a greater "absolute value". - Negative zero and positive zero are considered equal. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - An arbitrary-precision rational number to - compare with this one. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. - This implementation returns a positive number if 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.. - - - Compares the values of this object and another object, - imposing a total ordering on all possible values. In this method: - - For objects with the same value, the one with the higher - denominator has a greater "absolute value". - Negative zero is less than positive zero. - Quiet NaN has a higher "absolute value" than signaling NaN. - If both objects are quiet NaN or both are signaling NaN, the one - with the higher diagnostic information has a greater "absolute - value". - NaN has a higher "absolute value" than infinity. - Infinity has a higher "absolute value" than any finite - number. - Negative numbers are less than positive - numbers. - An arbitrary-precision rational number to - compare with this one. - The number 0 if both objects have the same value, or -1 if - this object is less than the other value, or 1 if this object is - greater. - This implementation returns a positive number if 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.. - - - Returns the absolute value of this rational number, that - is, a number with the same value as this one but as a nonnegative - number. - An arbitrary-precision rational number. - - - Adds this arbitrary-precision rational number and another - arbitrary-precision rational number and returns the - result. - Another arbitrary-precision rational - number. - The sum of the two numbers, that is, this - arbitrary-precision rational number plus another - arbitrary-precision rational number. - The parameter is null. - - - Compares the mathematical value of an arbitrary-precision - rational number with that of this instance. This method currently - uses the rules given in the CompareToValue method, so that it it is - not consistent with the Equals method, but it may change in a - future version to use the rules for the CompareToTotal method - instead. - An arbitrary-precision rational number. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is greater. - This implementation returns a positive number if 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.. - - - Compares the mathematical value of an arbitrary-precision - rational number with that of this instance. In this method, NaN - values are greater than any other ERational value, and two NaN - values (even if their payloads differ) are treated as equal by this - method. This method is not consistent with the Equals - method. - An arbitrary-precision rational number. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is greater. - This implementation returns a positive number if 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.. - - - Gets the greater value between two rational - numbers. - An arbitrary-precision rational number. - Another arbitrary-precision rational - number. - The larger value of the two numbers. If one is positive - zero and the other is negative zero, returns the positive zero. If - the two numbers are positive and have the same value, returns the - one with the larger denominator. If the two numbers are negative - and have the same value, returns the one with the smaller - denominator. - The parameter or is null. - - - Gets the greater value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Max. - The first value to compare. - The second value to compare. - The larger value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Gets the lesser value between two rational - numbers. - The first value to compare. - The second value to compare. - The smaller value of the two numbers. If one is positive - zero and the other is negative zero, returns the negative zero. If - the two numbers are positive and have the same value, returns the - one with the smaller denominator. If the two numbers are negative - and have the same value, returns the one with the larger - denominator. - The parameter or is null. - - - Gets the lesser value between two values, ignoring their - signs. If the absolute values are equal, has the same effect as - Min. - The first value to compare. - The second value to compare. - The smaller value of the two numbers, ignoring their - signs. - The parameter or is null. - - - Compares the mathematical value of an arbitrary-precision - rational number with that of this instance. This method currently - uses the rules given in the CompareToValue method, so that it it is - not consistent with the Equals method, but it may change in a - future version to use the rules for the CompareToTotal method - instead. - The parameter is - a 32-bit signed integer. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is - greater. - - - Compares the mathematical value of an arbitrary-precision - rational number with that of this instance. In this method, NaN - values are greater than any other ERational value, and two NaN - values (even if their payloads differ) are treated as equal by this - method. This method is not consistent with the Equals - method. - The parameter is - a 32-bit signed integer. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is - greater. - - - Compares the mathematical values of this object and - another object, accepting NaN values. - This method is not consistent with the Equals method because - two different numbers with the same mathematical value, but - different exponents, will compare as equal. - In this method, negative zero and positive zero are - considered equal. - If this object is a quiet NaN or signaling NaN, this method - will not trigger an error. Instead, NaN will compare greater than - any other number, including infinity. - The parameter is - a 64-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares the mathematical values of this object and - another object, accepting NaN values. This method currently uses - the rules given in the CompareToValue method, so that it it is not - consistent with the Equals method, but it may change in a future - version to use the rules for the CompareToTotal method - instead. - The parameter is - a 64-bit signed integer. - Less than 0 if this object's value is less than the other - value, or greater than 0 if this object's value is greater than the - other value, or 0 if both values are equal. - - - Compares an arbitrary-precision binary floating-point - number with this instance. In this method, NaN values are greater - than any other ERational or EFloat value, and two NaN values (even - if their payloads differ) are treated as equal by this - method. - An arbitrary-precision binary floating-point - number. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is greater. - This implementation returns a positive number if 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.. - - - Compares an arbitrary-precision decimal number with this - instance. - An arbitrary-precision decimal number. - Zero if the values are equal; a negative number if this - instance is less, or a positive number if this instance is greater. - This implementation returns a positive number if 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.. - - - Returns a number with the same value as this one, but - copying the sign (positive or negative) of another - number. - A number whose sign will be copied. - An arbitrary-precision rational number. - The parameter is null. - - - Divides this arbitrary-precision rational number by - another arbitrary-precision rational number and returns the - result. - An arbitrary-precision rational - number. - The result of dividing this arbitrary-precision rational - number by another arbitrary-precision rational number. - The parameter is null. - - - Determines whether this object's numerator, denominator, - and properties are equal to those of another object and that other - object is an arbitrary-precision rational number. Not-a-number - values are considered equal if the rest of their properties are - equal. This is not the same as value equality. Notably, two - ERationals with the same value, but of which one is in lowest terms - and the other is not, are compared as unequal by this method - (example: 1/2 vs. 5/10). - The parameter is an - arbitrary object. - true if the objects are equal; otherwise, - false. In this method, two objects are not equal if they - don't have the same type or if one is null and the other - isn't. - - - Determines whether this object's numerator, denominator, - and properties are equal to those of another object. Not-a-number - values are considered equal if the rest of their properties are - equal. - An arbitrary-precision rational number to - compare to. - Either true or false. - - - Returns the hash code for this instance. No application or - process IDs are used in the hash code calculation. - A 32-bit signed integer. - - - Gets a value indicating whether this object's value is - infinity. - true if this object's value is infinity; otherwise, - false. - - - Returns whether this object is a not-a-number - value. - true if this object is a not-a-number value; - otherwise, false. - - - Returns whether this object is negative - infinity. - true if this object is negative infinity; - otherwise, false. - - - Returns whether this object is positive - infinity. - true if this object is positive infinity; - otherwise, false. - - - Returns whether this object is a quiet not-a-number - value. - true if this object is a quiet not-a-number value; - otherwise, false. - - - Returns whether this object is a signaling not-a-number - value (which causes an error if the value is passed to any - arithmetic operation in this class). - true if this object is a signaling not-a-number - value (which causes an error if the value is passed to any - arithmetic operation in this class); otherwise, false. - - - Multiplies this arbitrary-precision rational number by - another arbitrary-precision rational number and returns the - result. - An arbitrary-precision rational - number. - The product of the two numbers, that is, this - arbitrary-precision rational number times another - arbitrary-precision rational number. - The parameter is null. - - - Returns a rational number with the same value as this one - but with the sign reversed. - An arbitrary-precision rational number. - - - Returns the remainder that would result when this - arbitrary-precision rational number is divided by another - arbitrary-precision rational number. - An arbitrary-precision rational - number. - The remainder that would result when this - arbitrary-precision rational number is divided by another - arbitrary-precision rational number. - The parameter is null. - - - Subtracts an arbitrary-precision rational number from this - arbitrary-precision rational number and returns the - result. - An arbitrary-precision rational - number. - The difference between the two numbers, that is, this - arbitrary-precision rational number minus another - arbitrary-precision rational number. - The parameter is null. - - - Converts this value to a 64-bit floating-point number. The - half-even rounding mode is used. - The closest 64-bit floating-point number to this value. - The return value can be positive infinity or negative infinity if - this value exceeds the range of a 64-bit floating point - number. - - - Converts this value to its closest equivalent as a 64-bit - floating-point number, expressed as an integer in the IEEE 754 - binary64 format. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 64-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. - The closest 64-bit binary floating-point number to this - value, expressed as an integer in the IEEE 754 binary64 format. The - return value can be positive infinity or negative infinity if this - value exceeds the range of a 64-bit floating point - number. - - - Converts this value to its closest equivalent as 32-bit - floating-point number, expressed as an integer in the IEEE 754 - binary32 format. The half-even rounding mode is used. - If this value is a NaN, sets the high bit of the 32-bit - floating point number's significand area for a quiet NaN, and - clears it for a signaling NaN. Then the other bits of the - significand area are set to the lowest bits of this object's - unsigned significand, and the next-highest bit of the significand - area is set if those bits are all zeros and this is a signaling - NaN. - The closest 32-bit binary floating-point number to this - value, expressed as an integer in the IEEE 754 binary32 format. The - return value can be positive infinity or negative infinity if this - value exceeds the range of a 32-bit floating point - number. - - - Converts this value to its form in lowest terms. For - example, (8/4) becomes (4/1). - An arbitrary-precision rational with the same value as - this one but in lowest terms. Returns this object if it is infinity - or NaN. Returns ERational.NegativeZero if this object is a negative - zero. Returns ERational.Zero if this object is a positive - zero. - This object's value is infinity - or not-a-number (NaN). - - - Converts this value to an arbitrary-precision integer by - dividing the numerator by the denominator, discarding its - fractional part, and checking whether the resulting integer - overflows the given signed bit count. - The maximum number of signed bits the - integer can have. The integer's value may not be less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN), or this number's value, once converted to an - integer by dividing the numerator by the denominator and discarding - its fractional part, is less than -(2^maxBitLength) or greater than - (2^maxBitLength) - 1. - - - Converts this value to an arbitrary-precision integer, - only if this number's value is an exact integer and that integer - does not overflow the given signed bit count. - The maximum number of signed bits the - integer can have. The integer's value may not be less than - -(2^maxBitLength) or greater than (2^maxBitLength) - 1. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN), or this number's value as an integer is less - than -(2^maxBitLength) or greater than (2^maxBitLength) - - 1. - This object's value is not an - exact integer. - - - Converts this value to an arbitrary-precision integer by - dividing the numerator by the denominator and discarding the - fractional part of the result. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - - - Converts this value to an arbitrary-precision integer, - checking whether the value is an exact integer. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - - - Converts this value to an arbitrary-precision integer, - checking whether the value is an exact integer. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - - - Converts this rational number to an arbitrary-precision - decimal number. - The exact value of the rational number, or not-a-number - (NaN) if the result can't be exact because it has a nonterminating - decimal expansion. - - - Converts this rational number to an arbitrary-precision - decimal number and rounds the result to the given - precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. If HasFlags - of the context is true, will also store the flags resulting from - the operation (the flags are in addition to the pre-existing - flags). Can be null, in which case the precision is unlimited and - no rounding is needed. - The value of the rational number, rounded to the given - precision. Returns not-a-number (NaN) if the context is null and - the result can't be exact because it has a nonterminating decimal - expansion. - - - Converts this rational number to an arbitrary-precision - decimal number, but if the result would have a nonterminating - decimal expansion, rounds that result to the given - precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only if the exact result would have a nonterminating - decimal expansion. If HasFlags of the context is true, will also - store the flags resulting from the operation (the flags are in - addition to the pre-existing flags). Can be null, in which case the - precision is unlimited and no rounding is needed. - The exact value of the rational number if possible; - otherwise, the rounded version of the result if a context is given. - Returns not-a-number (NaN) if the context is null and the result - can't be exact because it has a nonterminating decimal - expansion. - - - Converts this rational number to an arbitrary-precision - decimal number. - The exact value of the rational number, or not-a-number - (NaN) if the result can't be exact because it has a nonterminating - decimal expansion. - - - Converts this rational number to an arbitrary-precision - decimal number and rounds the result to the given - precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. If HasFlags - of the context is true, will also store the flags resulting from - the operation (the flags are in addition to the pre-existing - flags). Can be null, in which case the precision is unlimited and - no rounding is needed. - The value of the rational number, rounded to the given - precision. Returns not-a-number (NaN) if the context is null and - the result can't be exact because it has a nonterminating decimal - expansion. - - - Converts this rational number to an arbitrary-precision - decimal number, but if the result would have a nonterminating - decimal expansion, rounds that result to the given - precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only if the exact result would have a nonterminating - decimal expansion. If HasFlags of the context is true, will also - store the flags resulting from the operation (the flags are in - addition to the pre-existing flags). Can be null, in which case the - precision is unlimited and no rounding is needed. - The exact value of the rational number if possible; - otherwise, the rounded version of the result if a context is given. - Returns not-a-number (NaN) if the context is null and the result - can't be exact because it has a nonterminating decimal - expansion. - - - Converts this rational number to a binary floating-point - number. - The exact value of the rational number, or not-a-number - (NaN) if the result can't be exact because it has a nonterminating - binary expansion. - - - Converts this rational number to a binary floating-point - number and rounds that result to the given precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. If HasFlags - of the context is true, will also store the flags resulting from - the operation (the flags are in addition to the pre-existing - flags). Can be null, in which case the precision is unlimited and - no rounding is needed. - The value of the rational number, rounded to the given - precision. Returns not-a-number (NaN) if the context is null and - the result can't be exact because it has a nonterminating binary - expansion. - - - Converts this rational number to a binary floating-point - number, but if the result would have a nonterminating binary - expansion, rounds that result to the given precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only if the exact result would have a nonterminating - binary expansion. If HasFlags of the context is true, will also - store the flags resulting from the operation (the flags are in - addition to the pre-existing flags). Can be null, in which case the - precision is unlimited and no rounding is needed. - The exact value of the rational number if possible; - otherwise, the rounded version of the result if a context is given. - Returns not-a-number (NaN) if the context is null and the result - can't be exact because it has a nonterminating binary - expansion. - - - Converts this rational number to a binary floating-point - number. - The exact value of the rational number, or not-a-number - (NaN) if the result can't be exact because it has a nonterminating - binary expansion. - - - Converts this rational number to a binary floating-point - number and rounds that result to the given precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. If HasFlags - of the context is true, will also store the flags resulting from - the operation (the flags are in addition to the pre-existing - flags). Can be null, in which case the precision is unlimited and - no rounding is needed. - The value of the rational number, rounded to the given - precision. Returns not-a-number (NaN) if the context is null and - the result can't be exact because it has a nonterminating binary - expansion. - - - Converts this rational number to a binary floating-point - number, but if the result would have a nonterminating binary - expansion, rounds that result to the given precision. - An arithmetic context object to control the - precision, rounding, and exponent range of the result. This context - will be used only if the exact result would have a nonterminating - binary expansion. If HasFlags of the context is true, will also - store the flags resulting from the operation (the flags are in - addition to the pre-existing flags). Can be null, in which case the - precision is unlimited and no rounding is needed. - The exact value of the rational number if possible; - otherwise, the rounded version of the result if a context is given. - Returns not-a-number (NaN) if the context is null and the result - can't be exact because it has a nonterminating binary - expansion. - - - Converts this value to a 32-bit binary floating-point - number. The half-even rounding mode is used. - The closest 32-bit binary floating-point number to this - value. The return value can be positive infinity or negative - infinity if this value exceeds the range of a 32-bit floating point - number. - - - Converts this object to a text string. - A string representation of this object. If this object's - value is infinity or not-a-number, the result is the analogous - return value of the EDecimal.ToString method. Otherwise, the - return value has the following form: - [-]numerator/denominator. - - - Adds one to an arbitrary-precision rational - number. - The given arbitrary-precision rational number plus - one. - - - Subtracts one from an arbitrary-precision rational - number. - The given arbitrary-precision rational number minus - one. - - - Adds this arbitrary-precision rational number and a 32-bit - signed integer and returns the result. - A 32-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision rational number plus a 32-bit signed - integer. - - - Subtracts a 32-bit signed integer from this - arbitrary-precision rational number and returns the - result. - The parameter is a 32-bit - signed integer. - The difference between the two numbers, that is, this - arbitrary-precision rational number minus a 32-bit signed - integer. - - - Multiplies this arbitrary-precision rational number by a - 32-bit signed integer and returns the result. - The parameter is a 32-bit - signed integer. - The product of the two numbers, that is, this - arbitrary-precision rational number times a 32-bit signed - integer. - - - Divides this arbitrary-precision rational number by a - 32-bit signed integer and returns the result. - The parameter is a 32-bit - signed integer. - The result of dividing this arbitrary-precision rational - number by a 32-bit signed integer. - The parameter is zero. - - - Returns the remainder that would result when this - arbitrary-precision rational number is divided by a 32-bit signed - integer. - The divisor. - The remainder that would result when this - arbitrary-precision rational number is divided by a 32-bit signed - integer. - The parameter is zero. - - - Adds this arbitrary-precision rational number and a 64-bit - signed integer and returns the result. - A 64-bit signed integer. - The sum of the two numbers, that is, this - arbitrary-precision rational number plus a 64-bit signed - integer. - - - Subtracts a 64-bit signed integer from this - arbitrary-precision rational number and returns the - result. - The parameter is a 64-bit - signed integer. - The difference between the two numbers, that is, this - arbitrary-precision rational number minus a 64-bit signed - integer. - - - Multiplies this arbitrary-precision rational number by a - 64-bit signed integer and returns the result. - The parameter is a 64-bit - signed integer. - The product of the two numbers, that is, this - arbitrary-precision rational number times a 64-bit signed - integer. - - - Divides this arbitrary-precision rational number by a - 64-bit signed integer and returns the result. - The parameter is a 64-bit - signed integer. - The result of dividing this arbitrary-precision rational - number by a 64-bit signed integer. - The parameter is zero. - - - Returns the remainder that would result when this - arbitrary-precision rational number is divided by a 64-bit signed - integer. - The divisor. - The remainder that would result when this - arbitrary-precision rational number is divided by a 64-bit signed - integer. - The parameter is zero. - - - 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. - This number's value, truncated to a byte (from 0 to - 255). - 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. - - - Converts this number's value to an integer (using - ToEInteger), and returns the least-significant bits of that - integer's two's-complement form as a byte (from 0 to - 255). - This number, converted to a byte (from 0 to 255). Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a byte (from 0 to 255). - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 255. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - rational number. - The number to convert as a byte (from 0 to - 255). - This number's value as an arbitrary-precision rational - number. - - - 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. - This number's value, truncated to a 16-bit signed - integer. - 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. - - - 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. - This number, converted to a 16-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -32768 or - greater than 32767. - - - Converts a 16-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 16-bit signed - integer. - This number's value as an arbitrary-precision rational - number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -2147483648 - or greater than 2147483647. - - - Converts a boolean value (true or false) to an - arbitrary-precision rational number. - Either true or false. - The number 1 if is true; - otherwise, 0. - - - Converts a 32-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 32-bit signed - integer. - This number's value as an arbitrary-precision rational - number. - - - 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. - This number's value, truncated to a 64-bit signed - integer. - 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. - - - 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. - This number, converted to a 64-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than - -9223372036854775808 or greater than - 9223372036854775807. - - - Converts an unsigned integer expressed as a 64-bit signed - integer to an arbitrary-precision rational number. - A 64-bit signed integer. If this value is - 0 or greater, the return value will represent it. If this value is - less than 0, the return value will store 2^64 plus this value - instead. - An arbitrary-precision rational number. If is 0 or greater, the return value will - represent it. If is less than 0, the - return value will store 2^64 plus this value instead. - - - Converts a 64-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 64-bit signed - integer. - This number's value as an arbitrary-precision rational - number. - - - Converts a boolean value (true or false) to an - arbitrary-precision rational number. - Either true or false. - 1 if is true; otherwise, - 0. - - - Converts an arbitrary-precision integer to an - arbitrary-precision rational number. - An arbitrary-precision integer. - An arbitrary-precision rational number. - - - Converts an arbitrary-precision decimal floating-point - number to an arbitrary-precision rational number. - The parameter is an - arbitrary-precision decimal floating-point number. - An arbitrary-precision rational number. - - - Converts an arbitrary-precision binary floating-point - number to an arbitrary-precision rational number. - An arbitrary-precision binary floating-point - number. - An arbitrary-precision rational number. - - - Converts a decimal under the Common Language - Infrastructure (usually a.NET Framework decimal) to a rational - number. - The number to convert as a decimal under - the Common Language Infrastructure (usually a.NET Framework - decimal). - An arbitrary-precision rational number. - - - Converts a decimal under the Common Language - Infrastructure (usually a.NET Framework decimal). to an - arbitrary-precision rational number. - A decimal under the Common Language - Infrastructure (usually a.NET Framework decimal). - An arbitrary-precision rational number. - - - Converts a 32-bit binary floating-point number to a - rational number. - The parameter is a - 32-bit binary floating-point number. - The value of as an - arbitrary-precision rational number. - - - Converts a 64-bit floating-point number to an - arbitrary-precision rational number. - The parameter is a - 64-bit floating-point number. - An arbitrary-precision rational number. - - - Adds an arbitrary-precision rational number and another - arbitrary-precision rational number and returns the - result. - The first operand. - The second operand. - The sum of the two numbers, that is, an - arbitrary-precision rational number plus another - arbitrary-precision rational number. - The parameter "otherValue" - is null. - - - Subtracts an arbitrary-precision rational number from this - instance. - The first operand. - The second operand. - The difference of the two objects. - The parameter "otherValue" - is null. - - - Adds one to an arbitrary-precision rational - number. - An arbitrary-precision rational number. - The number given in plus - one. - The parameter is null. - - - Subtracts one from an arbitrary-precision rational - number. - An arbitrary-precision rational number. - The number given in minus - one. - The parameter is null. - - - Multiplies an arbitrary-precision rational number by - another arbitrary-precision rational number and returns the - result. - The first operand. - The second operand. - The product of the two numbers, that is, an - arbitrary-precision rational number times another - arbitrary-precision rational number. - The parameter "otherValue" - is null. - - - Divides an arbitrary-precision rational number by the - value of another arbitrary-precision rational number - object. - An arbitrary-precision rational number - serving as the dividend. - An arbitrary-precision rational number - serving as the divisor. - The quotient of the two objects. - The parameter "otherValue" - is null. - - - Returns the remainder that would result when an - arbitrary-precision rational number is divided by another - arbitrary-precision rational number. - The dividend. - The divisor. - The remainder that would result when an - arbitrary-precision rational number is divided by another - arbitrary-precision rational number. - The parameter "otherValue" - is null. - - - Returns an arbitrary-precision rational number with the - same value as the given one but with its sign reversed. - An arbitrary-precision rational number to - negate. - An arbitrary-precision rational number. - The parameter is null. - - - Converts this value to a decimal under the Common - Language Infrastructure (usually a.NET Framework decimal). - Currently, converts this value to the precision and range of a.NET - Framework decimal. - A decimal under the Common Language Infrastructure - (usually a.NET Framework decimal). - - - Converts an arbitrary-precision rational number to a - decimal under the Common Language Infrastructure (see - "Forms of numbers" - ). - The number to convert as an - arbitrary-precision rational number. - A decimal under the Common Language Infrastructure - (usually a.NET Framework decimal). - The parameter is null. - - - Converts an arbitrary-precision rational number to an - arbitrary-precision integer. Any fractional part in the value will - be discarded when converting to an arbitrary-precision - integer. - An arbitrary-precision rational - number. - An arbitrary-precision integer. - This object's value is infinity - or not-a-number (NaN). - The parameter is null. - - - Converts an arbitrary-precision rational number to a - 64-bit floating-point number. The half-even rounding mode is - used. - The number to convert as an - arbitrary-precision rational number. - The closest 64-bit floating-point number to this value. - The return value can be positive infinity or negative infinity if - this value exceeds the range of a 64-bit floating point - number. - The parameter is null. - - - Converts an arbitrary-precision rational number to a - 32-bit binary floating-point number. The half-even rounding mode is - used. - The number to convert as an - arbitrary-precision rational number. - The closest 32-bit binary floating-point number to this - value. The return value can be positive infinity or negative - infinity if this value exceeds the range of a 32-bit floating point - number. - The parameter is null. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - byte (from 0 to 255). - The parameter 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. - The parameter is null. - - - Converts a byte (from 0 to 255) to an arbitrary-precision - rational number. - The number to convert as a byte (from 0 to - 255). - The value of as an - arbitrary-precision rational number. - - - 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. - This number's value, truncated to an 8-bit signed - integer. - 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. - - - 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. - This number, converted to an 8-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as an 8-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than -128 or - greater than 127. - - - Converts an 8-bit signed integer to an arbitrary-precision - rational number. - The number to convert as an 8-bit signed - integer. - This number's value as an arbitrary-precision rational - number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to an - 8-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts an 8-bit signed integer to an arbitrary-precision - rational number. - The number to convert as an 8-bit signed - integer. - The value of as an - arbitrary-precision rational number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - 16-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 16-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 16-bit signed - integer. - The value of as an - arbitrary-precision rational number. - - - 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. - This number's value, truncated to a 16-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 16-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 16-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 65535. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision rational number. - The number to convert as a 16-bit - unsigned integer. - This number's value as an arbitrary-precision rational - number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - 16-bit unsigned integer. - The parameter 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. - The parameter is null. - - - Converts a 16-bit unsigned integer to an - arbitrary-precision rational number. - The number to convert as a 16-bit - unsigned integer. - The value of as an - arbitrary-precision rational number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - 32-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision rational number. - - - 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. - This number's value, truncated to a 32-bit signed - integer. - 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. - - - 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. - This number, converted to a 32-bit signed integer. Returns - 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 32-bit signed integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 4294967295. - - - Converts a 32-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 32-bit signed - integer. - This number's value as an arbitrary-precision rational - number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - 32-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 32-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 32-bit signed - integer. - The value of as an - arbitrary-precision rational number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - 64-bit signed integer. - The parameter 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. - The parameter is null. - - - Converts a 64-bit signed integer to an arbitrary-precision - rational number. - The number to convert as a 64-bit signed - integer. - The value of as an - arbitrary-precision rational number. - - - 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. - This number's value, truncated to a 64-bit unsigned - integer. - 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. - - - 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. - This number, converted to a 64-bit unsigned integer. - Returns 0 if this value is infinity or not-a-number. - - - 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. - This number's value as a 64-bit unsigned - integer. - This value is infinity or - not-a-number, is not an exact integer, or is less than 0 or greater - than 18446744073709551615. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision rational number. - The number to convert as a 64-bit - unsigned integer. - This number's value as an arbitrary-precision rational - number. - - - Converts an arbitrary-precision rational number 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. - The number to convert as an arbitrary-precision - rational number. - The value of , truncated to a - 64-bit unsigned integer. - The parameter 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. - The parameter is null. - - - Converts a 64-bit unsigned integer to an - arbitrary-precision rational number. - The number to convert as a 64-bit - unsigned integer. - The value of as an - arbitrary-precision rational number. - - - Specifies the mode to use when "shortening" numbers that - otherwise can't fit a given number of digits, so that the shortened - number has about the same value. This "shortening" is known as - rounding. (The "E" stands for "extended", and has this prefix to - group it with the other classes common to this library, - particularly EDecimal, EFloat, and ERational.). - - - Indicates that rounding will not be used. If rounding to - an inexact value is required, the rounding operation will report an - error. - - - If there is a fractional part, the number is rounded to - the closest representable number away from zero. - - - The fractional part is discarded (the number is - truncated). - - - Rounded to the nearest number; if the fractional part is - exactly half, the number is rounded to the closest representable - number away from zero. This is the most familiar rounding mode for - many people. - - - Rounded to the nearest number; if the fractional part is - exactly half, it is discarded. - - - Rounded to the nearest number; if the fractional part is - exactly half, the number is rounded to the closest representable - number that is even. This is sometimes also known as "banker's - rounding". - - - If there is a fractional part, the number is rounded to - the highest representable number that's closest to it. - - - If there is a fractional part, the number is rounded to - the lowest representable number that's closest to it. - - - If there is a fractional part and the whole number part is - even, the number is rounded to the closest representable odd number - away from zero. - - - If there is a fractional part and if the last digit before - rounding is 0 or half the radix, the number is rounded to the - closest representable number away from zero; otherwise the - fractional part is discarded. In overflow, the fractional part is - always discarded. - - - For binary floating point numbers, this is the same as - Odd. For other bases (including decimal numbers), this is the same - as ZeroFiveUp. This rounding mode is useful for rounding - intermediate results at a slightly higher precision (at least 2 - bits more for binary) than the final precision. - - - Exception thrown for arithmetic trap errors. (The "E" - stands for "extended", and has this prefix to group it with the - other classes common to this library, particularly EDecimal, - EFloat, and ERational.). - This library may throw exceptions of this type in certain - cases, notably when errors occur, and may supply messages to those - exceptions (the message can be accessed through the Message - property in.NET or the getMessage() method in Java). These - messages are intended to be read by humans to help diagnose the - error (or other cause of the exception); they are not intended to - be parsed by computer programs, and the exact text of the messages - may change at any time between versions of this - library. - - - Gets the arithmetic context used during the operation that - triggered the trap. May be null. - The arithmetic context used during the operation that - triggered the trap. May be null. - - - Initializes a new instance of the - class. - - - Initializes a new instance of the - class. - The parameter is a - text string. - - - Initializes a new instance of the - class. - The parameter is a - text string. - The parameter is an Exception object. - - - Gets the defined result of the operation that caused the - trap. - The defined result of the operation that caused the - trap. - - - Gets the flag that specifies the primary kind of error in - one or more operations (EContext.FlagXXX). This will only be one - flag, such as FlagInexact or FlagSubnormal. - The flag that specifies the primary kind of error in one or - more operations. - - - Gets the flags that were signaled as the result of one or - more operations. This includes the flag specified in the "flag" - parameter, but can include other flags. For instance, if "flag" is - EContext.FlagInexact, this parameter might be - EContext.FlagInexact | EContext.FlagRounded. - The flags that specify the errors in one or more - operations. - - - Returns whether this trap exception specifies all the - flags given. (Flags are signaled in a trap exception as the result - of one or more operations involving arbitrary-precision numbers, - such as multiplication of two EDecimals.). - A combination of one or more flags, such as - EContext.FlagInexact | EContext.FlagRounded. - True if this exception pertains to all of the flags given - in ; otherwise, false. - - - Initializes a new instance of the - class. - The flag that specifies the kind of error from - one or more operations (EContext.FlagXXX). This will only be one - flag, such as FlagInexact or FlagSubnormal. - The arithmetic context used during the operation - that triggered the trap. Can be null. - The defined result of the operation that - caused the trap. - - - Initializes a new instance of the - class. - Specifies the flags that were signaled as the - result of one or more operations. This includes the flag specified - in the "flag" parameter, but can include other flags. For instance, - if "flag" is EContext.FlagInexact, this parameter might be - EContext.FlagInexact | EContext.FlagRounded. - Specifies the flag that specifies the primary - kind of error from one or more operations (EContext.FlagXXX). This - will only be one flag, such as FlagInexact or - FlagSubnormal. - The arithmetic context used during the operation - that triggered the trap. Can be null. - The defined result of the operation that - caused the trap. - The parameter doesn't include all the flags in the parameter. - - - This is an internal API. - The parameter is an - internal value. - A FastInteger object. - - - This is an internal API. - A FastInteger object. - - - This is an internal API. - The parameter is an - internal value. - A FastInteger object. - - - This is an internal API. - The parameter is an - internal value. - A FastInteger object. - - - This is an internal API. - The parameter - is an internal value. - A FastInteger object. - - - This is an internal API. - The parameter - is an internal value. - A FastInteger object. - - - This is an internal API. - A text string. - - - Gets an internal value. - An internal value. - - - This is an internal API. - A text string. - - - Common interface for classes that shift a number of digits - and record information on whether a non-zero digit was discarded - this way. - - - diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.dll b/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.dll index 598987e2..05391818 100644 Binary files a/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.dll and b/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.dll differ diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.xml b/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.xml index 11147e22..a270fefc 100644 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.xml +++ b/PubNubUnity/Assets/PubNub/Runtime/Plugins/PubnubApiUnity.xml @@ -102,6 +102,47 @@ + + + A simple not-all-covering implementation of CBOR serialisation/deserialisation for internal Pubnub ParseToken() usage + Converted to C# from https://github.com/seba-aln/CBORCodec + + + + + Decode incoming hexadecimal string of data and outputing decoded values + + Hexadecimal string to decode + Decoded value + Thrown when input is invalid or unsupported type + + + + Removes spaces, converts string to upper case and throws exception if input is not a valid hexadecimal string + + Input string to sanitize + Sanitized hexadecimal string + Thrown when input contains invalid characters + + + + Sanitizes the output value so it contains even number of characters and returns it upper cased + + Hexadecimal value to sanitize + Should the length of output be in powers of two (2, 4, 8, 16) + Sanitized hexadecimal string + + + + Encodes value to a hexadecimal CBOR string. Because C# does not differentiate byte strings and text strings + the only way to manipulate output type of strings is to pass a string type (one of CBOR::TYPE_TEXT_STRING and + CBOR::TYPE_BYTE_STRING). + + Value to encode + Type of string encoding + Hexadecimal CBOR string + Thrown when unsupported type is passed + Dispatch an invocation i.e. call a registered effect handler. diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.dll b/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.dll deleted file mode 100644 index 32bd6f08..00000000 Binary files a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.dll and /dev/null differ diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.dll.meta b/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.dll.meta deleted file mode 100644 index 02ec91df..00000000 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 6fdc91b76c97641459bbfe0e1d232f17 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.xml b/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.xml deleted file mode 100644 index 82310efb..00000000 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.xml +++ /dev/null @@ -1,378 +0,0 @@ - - - - URIUtility - - - - Contains utility methods for processing Uniform Resource - Identifiers (URIs) and Internationalized Resource Identifiers - (IRIs) under RFC3986 and RFC3987, respectively. In the following - documentation, URIs and IRIs include URI references and IRI - references, for convenience. - There are five components to a URI: scheme, authority, path, - query, and fragment identifier. The generic syntax to these - components is defined in RFC3986 and extended in RFC3987. According - to RFC3986, different URI schemes can further restrict the syntax - of the authority, path, and query component (see also RFC 7320). - However, the syntax of fragment identifiers depends on the media - type (also known as MIME type) of the resource a URI references - (see also RFC 3986 and RFC 7320). As of September 3, 2019, only the - following media types specify a syntax for fragment - identifiers: - - The following application/* media types: epub + zip, pdf, - senml + cbor, senml + json, senml-exi, sensml + cbor, sensml + - json, sensml-exi, smil, vnd.3gpp-v2x-local-service-information, - vnd.3gpp.mcdata-signalling, vnd.collection.doc + json, vnd.hc + - json, vnd.hyper + json, vnd.hyper-item + json, vnd.mason + json, - vnd.microsoft.portable-executable, vnd.oma.bcast.sgdu, - vnd.shootproof + json - The following image/* media types: avci, avcs, heic, - heic-sequence, heif, heif-sequence, hej2k, hsj2, jxra, jxrs, jxsi, - jxss - The XML media types: application/xml, - application/xml-external-parsed-entity, text/xml, - text/xml-external-parsed-entity, application/xml-dtd - All media types with subtypes ending in "+xml" (see RFC 7303) - use XPointer Framework syntax as fragment identifiers, except the - following application/* media types: dicom + xml (syntax not - defined), senml + xml (own syntax), sensml + xml (own syntax), ttml - + xml (own syntax), xliff + xml (own syntax), yang-data + xml - (syntax not defined) - font/collection - multipart/x-mixed-replace - text/plain - text/csv - text/html - text/markdown - text/vnd.a - - - Specifies whether certain characters are allowed when - parsing IRIs and URIs. - - - The rules follow the syntax for parsing IRIs. In - particular, many code points outside the Basic Latin range (U+0000 - to U+007F) are allowed. Strings with unpaired surrogate code points - are considered invalid. - - - The rules follow the syntax for parsing IRIs, except that - code points outside the Basic Latin range (U+0000 to U+007F) are - not allowed. - - - The rules only check for the appropriate delimiters when - splitting the path, without checking if all the characters in each - component are valid. Even with this mode, strings with unpaired - surrogate code points are considered invalid. - - - The rules only check for the appropriate delimiters when - splitting the path, without checking if all the characters in each - component are valid. Code points outside the Basic Latin range - (U+0000 to U+007F) are not allowed. - - - The rules only check for the appropriate delimiters when - splitting the path, without checking if all the characters in each - component are valid. Unpaired surrogate code points are treated as - though they were replacement characters instead for the purposes of - these rules, so that strings with those code points are not - considered invalid strings. - - - Escapes characters that can't appear in URIs or IRIs. The - function is idempotent; that is, calling the function again on the - result with the same mode doesn't change the result. - A string to escape. - Has the following meaning: 0 = Encode reserved - code points, code points below U+0021, code points above U+007E, - and square brackets within the authority component, and do the - IRISurrogateLenient check. 1 = Encode code points above U+007E, and - square brackets within the authority component, and do the - IRIStrict check. 2 = Same as 1, except the check is - IRISurrogateLenient. 3 = Same as 0, except that percent characters - that begin illegal percent-encoding are also encoded. - A string possibly containing escaped characters, or null - if s is null. - - - - Determines whether the string is a valid IRI with a - scheme component. This can be used to check for - relative IRI references. - The following cases return true: - xx-x:mm example:/ww - The following cases return false: - x@y:/z /x/y/z example.xyz - . - - A string representing an IRI to - check. - true - if the string is a valid IRI with a scheme - component; otherwise, false - . - - - - Determines whether the string is a valid URI with a - scheme component. This can be used to check for - relative URI references. The following cases return - true: - http://example/z xx-x:mm example:/ww - The following cases return false: - x@y:/z /x/y/z example.xyz - . - - A string representing an IRI to - check. - true - if the string is a valid URI with a scheme - component; otherwise, false - . - - - Decodes percent-encoding (of the form "%XX" where X is a - hexadecimal digit) in the given string. Successive percent-encoded - bytes are assumed to form characters in UTF-8. - A string that may contain percent encoding. May - be null. - The string in which percent-encoding was - decoded. - - - Decodes percent-encoding (of the form "%XX" where X is a - hexadecimal digit) in the given portion of a string. Successive - percent-encoded bytes are assumed to form characters in - UTF-8. - A string a portion of which may contain percent - encoding. May be null. - Index starting at 0 showing where the desired - portion of begins. - Index starting at 0 showing where the - desired portion of ends. The character - before this index is the last character. - The portion of the given string in which percent-encoding - was decoded. Returns null if is - ull. - - - Encodes characters other than "unreserved" characters for - URIs. - A string to encode. - The encoded string. - The parameter is null. - - - Determines whether the substring is a valid CURIE - reference under RDFA 1.1. (The CURIE reference is the part after - the colon.). - A string containing a CURIE reference. Can be - null. - A Index starting at 0 showing where the - desired portion of "s" begins. - The number of elements in the desired portion - of "s" (but not more than "s" 's length). - true if the substring is a valid CURIE reference - under RDFA 1; otherwise, false. Returns false if is null. - Either or is less than 0 or - greater than 's length, or ' s length minus is less than - . - The parameter is null. - - - Builds an internationalized resource identifier (IRI) from - its components. - String representing a scheme - component, an authority component, or both. Examples of this - parameter include "example://example", "example:", and "//example", - but not "example". Can be null or empty. - A string representing a path component. Can be - null or empty. - The query string. Can be null or empty. - The fragment identifier. Can be null or - empty. - A URI built from the given components. - Invalid schemeAndAuthority - parameter, or the arguments result in an invalid IRI. - - - Returns whether a string is a valid IRI according to the - IRIStrict parse mode. - A text string. Can be null. - True if the string is not null and is a valid IRI; - otherwise, false. - - - Returns whether a string is a valid IRI according to the - given parse mode. - A text string. Can be null. - The parse mode to use when checking for a valid - IRI. - True if the string is not null and is a valid IRI; - otherwise, false. - - - Resolves a URI or IRI relative to another URI or - IRI. - A string representing a URI or IRI - reference. Example: dir/file.txt. - A string representing an absolute URI or - IRI reference. Can be null. Example: - http://example.com/my/path/. - The resolved IRI, or null if - is null or is not a valid IRI. If - is null or is not a valid IRI, returns refValue. Example: - http://example.com/my/path/dir/file.txt. - - - Resolves a URI or IRI relative to another URI or - IRI. - A string representing a URI or IRI - reference. Example: dir/file.txt. Can be null. - A string representing an absolute URI or - IRI reference. Can be null. Example: - http://example.com/my/path/. - Parse mode that specifies whether certain - characters are allowed when parsing IRIs and URIs. - The resolved IRI, or null if - is null or is not a valid IRI. If - is null or is not a valid IRI, returns refValue. - The parameter or or or is - null. - - - Parses an Internationalized Resource Identifier (IRI) - reference under RFC3987. If the IRI reference is syntactically - valid, splits the string into its components and returns an array - containing those components. - A string that contains an IRI. Can be null. - If the string is a valid IRI reference, returns an array - of five strings. Each of the five pairs corresponds to the IRI's - scheme, authority, path, query, or fragment identifier, - respectively. If a component is absent, the corresponding element - will be null. If the string is null or is not a valid IRI, returns - null. - - - Parses an Internationalized Resource Identifier (IRI) - reference under RFC3987. If the IRI reference is syntactically - valid, splits the string into its components and returns an array - containing the indices into the components. - A string that contains an IRI. Can be null. - If the string is a valid IRI reference, returns an array - of 10 integers. Each of the five pairs corresponds to the start and - end index of the IRI's scheme, authority, path, query, or fragment - identifier, respectively. The scheme, authority, query, and - fragment identifier, if present, will each be given without the - ending colon, the starting "//", the starting "?", and the starting - "#", respectively. If a component is absent, both indices in that - pair will be -1. If the string is null or is not a valid IRI, - returns null. - - - Parses a substring that represents an Internationalized - Resource Identifier (IRI) under RFC3987. If the IRI is - syntactically valid, splits the string into its components and - returns an array containing the indices into the - components. - A string that contains an IRI. Can be null. - A Index starting at 0 showing where the - desired portion of "s" begins. - The length of the desired portion of "s" (but - not more than "s" 's length). - Parse mode that specifies whether certain - characters are allowed when parsing IRIs and URIs. - If the string is a valid IRI, returns an array of 10 - integers. Each of the five pairs corresponds to the start and end - index of the IRI's scheme, authority, path, query, or fragment - component, respectively. The scheme, authority, query, and fragment - components, if present, will each be given without the ending - colon, the starting "//", the starting "?", and the starting "#", - respectively. If a component is absent, both indices in that pair - will be -1 (an index won't be less than 0 in any other case). If - the string is null or is not a valid IRI, returns null. - Either or is less than 0 or - greater than 's length, or ' s length minus is less than - . - The parameter is null. - - - Parses an Internationalized Resource Identifier (IRI) - reference under RFC3987. If the IRI is syntactically valid, splits - the string into its components and returns an array containing the - indices into the components. - A string representing an IRI. Can be null. - The parameter - is a ParseMode object. - If the string is a valid IRI reference, returns an array - of 10 integers. Each of the five pairs corresponds to the start and - end index of the IRI's scheme, authority, path, query, or fragment - identifier, respectively. The scheme, authority, query, and - fragment identifier, if present, will each be given without the - ending colon, the starting "//", the starting "?", and the starting - "#", respectively. If a component is absent, both indices in that - pair will be -1. If the string is null or is not a valid IRI, - returns null. - - - Extracts the scheme, the authority, and the path component - (up to and including the last "/" in the path if any) from the - given URI or IRI, using the IRIStrict parse mode to check the URI - or IRI. Any "./" or "../" in the path is not condensed. - A text string representing a URI or IRI. Can be - null. - The directory path of the URI or IRI. Returns null if - is null or not a valid URI or - IRI. - The parameter is null. - - - Extracts the scheme, the authority, and the path component - (up to and including the last "/" in the path if any) from the - given URI or IRI, using the given parse mode to check the URI or - IRI. Any "./" or "../" in the path is not condensed. - A text string representing a URI or IRI. Can be - null. - The parse mode to use to check the URI or - IRI. - The directory path of the URI or IRI. Returns null if - is null or not a valid URI or - IRI. - - - Resolves a URI or IRI relative to another URI or IRI, but - only if the resolved URI has no "." or ".." component in its path - and only if resolved URI's directory path matches that of the - second URI or IRI. - A string representing a URI or IRI - reference. Example: dir/file.txt. - A string representing an absolute URI - reference. Example: http://example.com/my/path/. - The resolved IRI, or null if - is null or is not a valid IRI, or if - is null or an empty string, or null - if is neither null nor empty and is - not a valid IRI. Returns null instead if the resolved IRI has no - "." or ".." component in its path or if the resolved URI's - directory path does not match that of . Example: - http://example.com/my/path/dir/file.txt. - - - diff --git a/PubNubUnity/Assets/PubNub/Runtime/Util/PNManagerBehaviour.cs b/PubNubUnity/Assets/PubNub/Runtime/Util/PNManagerBehaviour.cs index de42dc20..980c5d5e 100644 --- a/PubNubUnity/Assets/PubNub/Runtime/Util/PNManagerBehaviour.cs +++ b/PubNubUnity/Assets/PubNub/Runtime/Util/PNManagerBehaviour.cs @@ -31,18 +31,10 @@ public Pubnub Initialize(string userId) { return pubnub; } - pnConfiguration.UserId = userId; - var pnConfig = ((PNConfiguration)pnConfiguration); - pubnub = pnConfiguration.EnableWebGLBuildMode - ? new Pubnub(pnConfig, httpTransportService: new UnityWebGLHttpClientService(), - ipnsdkSource: new UnityPNSDKSource()) - : new Pubnub(pnConfig, ipnsdkSource: new UnityPNSDKSource()); - if (pnConfiguration.LogToUnityConsole) { - pubnub.SetLogger(new UnityPubNubLogger(pubnub.InstanceId)); - } - pubnub.SetJsonPluggableLibrary(new NewtonsoftJsonUnity(pnConfig)); + pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration, userId); pubnub.AddListener(listener); return pubnub; + } protected virtual void OnDestroy() { diff --git a/PubNubUnity/Assets/PubNub/Runtime/Util/PubnubUnityUtils.cs b/PubNubUnity/Assets/PubNub/Runtime/Util/PubnubUnityUtils.cs new file mode 100644 index 00000000..d127bda4 --- /dev/null +++ b/PubNubUnity/Assets/PubNub/Runtime/Util/PubnubUnityUtils.cs @@ -0,0 +1,34 @@ +namespace PubnubApi.Unity { + public static class PubnubUnityUtils { + /// + /// Creates a new Pubnub instance with Unity specific settings (like WebGL setup, logging, and JSON library) + /// + /// Pubnub configuration object + /// Flag for enabling WebGL mode - sets httpTransportService to UnityWebGLHttpClientService + /// Flag to set Unity specific logger (UnityPubNubLogger) + /// + public static Pubnub NewUnityPubnub(PNConfiguration configuration, bool webGLBuildMode = false, bool unityLogging = false) { + var pubnub = webGLBuildMode + ? new Pubnub(configuration, httpTransportService: new UnityWebGLHttpClientService(), + ipnsdkSource: new UnityPNSDKSource()) + : new Pubnub(configuration, ipnsdkSource: new UnityPNSDKSource()); + if (unityLogging) { + pubnub.SetLogger(new UnityPubNubLogger(pubnub.InstanceId)); + } + pubnub.SetJsonPluggableLibrary(new NewtonsoftJsonUnity(configuration)); + return pubnub; + } + + /// + /// Creates a new Pubnub instance with Unity specific settings (like WebGL setup, logging, and JSON library) + /// + /// Pubnub configuration Scriptable Object asset + /// Client user ID for this instance + /// + public static Pubnub NewUnityPubnub(PNConfigAsset configurationAsset, string userId) { + configurationAsset.UserId = userId; + var pnConfig = ((PNConfiguration)configurationAsset); + return NewUnityPubnub(pnConfig, configurationAsset.EnableWebGLBuildMode, configurationAsset.LogToUnityConsole); + } + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/PubNub/Runtime/Util/PubnubUnityUtils.cs.meta b/PubNubUnity/Assets/PubNub/Runtime/Util/PubnubUnityUtils.cs.meta new file mode 100644 index 00000000..6280bb17 --- /dev/null +++ b/PubNubUnity/Assets/PubNub/Runtime/Util/PubnubUnityUtils.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d793402d3dca47048dc54bece922054c +timeCreated: 1750938569 \ No newline at end of file diff --git a/PubNubUnity/Assets/PubNub/Runtime/Util/UnityPNSDKSource.cs b/PubNubUnity/Assets/PubNub/Runtime/Util/UnityPNSDKSource.cs index d1409304..502de7b9 100644 --- a/PubNubUnity/Assets/PubNub/Runtime/Util/UnityPNSDKSource.cs +++ b/PubNubUnity/Assets/PubNub/Runtime/Util/UnityPNSDKSource.cs @@ -5,7 +5,7 @@ namespace PubnubApi.Unity { public class UnityPNSDKSource : IPNSDKSource { - private const string build = "9.0.1"; + private const string build = "9.1.0"; public string GetPNSDK() { #if(UNITY_IOS) diff --git a/PubNubUnity/Assets/PubNub/package.json b/PubNubUnity/Assets/PubNub/package.json index 349e790a..2c66cc7c 100644 --- a/PubNubUnity/Assets/PubNub/package.json +++ b/PubNubUnity/Assets/PubNub/package.json @@ -1,6 +1,6 @@ { "name": "com.pubnub.sdk", - "version": "9.0.1", + "version": "9.1.0", "displayName": "PubNub SDK", "description": "PubNub Real-time Cloud-Hosted Push API and Push Notification Client Frameworks", "unity": "2018.2", diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.xml.meta b/PubNubUnity/Assets/Snippets.meta similarity index 57% rename from PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.xml.meta rename to PubNubUnity/Assets/Snippets.meta index bffeb029..f40d8fb4 100644 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/Numbers.xml.meta +++ b/PubNubUnity/Assets/Snippets.meta @@ -1,6 +1,7 @@ fileFormatVersion: 2 -guid: 8f704e9f368b35d48b1f0294c76313ec -TextScriptImporter: +guid: 724dda23b1698074d8037cc7721395e1 +folderAsset: yes +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.xml.meta b/PubNubUnity/Assets/Snippets/AccessManager.meta similarity index 57% rename from PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.xml.meta rename to PubNubUnity/Assets/Snippets/AccessManager.meta index 649b5e01..959723ea 100644 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/URIUtility.xml.meta +++ b/PubNubUnity/Assets/Snippets/AccessManager.meta @@ -1,6 +1,7 @@ fileFormatVersion: 2 -guid: fa1f8f3af7c5b4b42ad2845f93eac01b -TextScriptImporter: +guid: 1ea0a53e383d01847a46bb75f0bfb127 +folderAsset: yes +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerSample.cs b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerSample.cs new file mode 100644 index 00000000..6e080078 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerSample.cs @@ -0,0 +1,372 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +using UnityEngine; + +class AccessManagerSample +{ + private static Pubnub pubnub; + + static void PubnubInit() + { + // snippet.pubnub_init + //Create configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "YOUR_SUBSCRIBE_KEY", + PublishKey = "YOUR_PUBLISH_KEY", + SecretKey = "YOUR_SECRET_KEY", + }; + //Create a new PubNub instance + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + static async Task GrantTokenComplex() + { + // snippet.grant_token_complex + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUuid("my-authorized-uuid") + .Resources(new PNTokenResources() + { + Channels = new Dictionary() { + { "channel-a", new PNTokenAuthValues() { Read = true } }, + { "channel-b", new PNTokenAuthValues() { Read = true, Write = true } }, + { "channel-c", new PNTokenAuthValues() { Read = true, Write = true } }, + { "channel-d", new PNTokenAuthValues() { Read = true, Write = true } }}, + ChannelGroups = new Dictionary() { + { "channel-group-b", new PNTokenAuthValues() { Read = true } } }, + Uuids = new Dictionary() { + { "uuid-c", new PNTokenAuthValues() { Get = true } }, + { "uuid-d", new PNTokenAuthValues() { Get = true, Update = true } }} + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task GrantTokenWithRegex() + { + // snippet.grant_token_regex + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUuid("my-authorized-uuid") + .Patterns(new PNTokenPatterns() + { + Channels = new Dictionary() { + { "channel-[A-Za-z0-9]", new PNTokenAuthValues() { Read = true } }} + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task GrantTokenComplexWithRegex() + { + // snippet.grant_token_complex_with_regex + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUuid("my-authorized-uuid") + .Resources(new PNTokenResources() + { + Channels = new Dictionary() { + { "channel-a", new PNTokenAuthValues() { Read = true } }, + { "channel-b", new PNTokenAuthValues() { Read = true, Write = true } }, + { "channel-c", new PNTokenAuthValues() { Read = true, Write = true } }, + { "channel-d", new PNTokenAuthValues() { Read = true, Write = true } }}, + ChannelGroups = new Dictionary() { + { "channel-group-b", new PNTokenAuthValues() { Read = true } } }, + Uuids = new Dictionary() { + { "uuid-c", new PNTokenAuthValues() { Get = true } }, + { "uuid-d", new PNTokenAuthValues() { Get = true, Update = true } }} + }) + .Patterns(new PNTokenPatterns() + { + Channels = new Dictionary() { + { "channel-[A-Za-z0-9]", new PNTokenAuthValues() { Read = true } }} + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task GrantTokenOldBasicUsage() + { + // snippet.basic_usage_old + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUserId("my-authorized-userId") + .Resources(new PNTokenResources() + { + Spaces = new Dictionary() { + { "my-space", new PNTokenAuthValues() { Read = true } } } // False to disallow + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + //PNAccessManagerTokenResult is a parsed and abstracted response from the server + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task GrantTokenOldComplex() + { + // snippet.grant_token_complex_old + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUserId("my-authorized-userId") + .Resources(new PNTokenResources() + { + Spaces = new Dictionary() { + { "space-a", new PNTokenAuthValues() { Read = true } }, + { "space-b", new PNTokenAuthValues() { Read = true, Write = true } }, + { "space-c", new PNTokenAuthValues() { Read = true, Write = true } }, + { "space-d", new PNTokenAuthValues() { Read = true, Write = true } }}, + Users = new Dictionary() { + { "user-c", new PNTokenAuthValues() { Get = true } }, + { "user-d", new PNTokenAuthValues() { Get = true, Update = true } }} + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task GrantTokenOldWithRegex() + { + // snippet.grant_token_old_regex + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUserId("my-authorized-userId") + .Patterns(new PNTokenPatterns() + { + Spaces = new Dictionary() { + { "space-[A-Za-z0-9]", new PNTokenAuthValues() { Read = true } }} + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task GrantTokenOldComplexWithRegex() + { + // snippet.grant_token_complex_old_with_regex + PNResult grantTokenResponse = await pubnub.GrantToken() + .TTL(15) + .AuthorizedUserId("my-authorized-userId") + .Resources(new PNTokenResources() + { + Spaces = new Dictionary() { + { "space-a", new PNTokenAuthValues() { Read = true } }, + { "space-b", new PNTokenAuthValues() { Read = true, Write = true } }, + { "space-c", new PNTokenAuthValues() { Read = true, Write = true } }, + { "space-d", new PNTokenAuthValues() { Read = true, Write = true } }}, + Users = new Dictionary() { + { "user-c", new PNTokenAuthValues() { Get = true } }, + { "user-d", new PNTokenAuthValues() { Get = true, Update = true } }} + }) + .Patterns(new PNTokenPatterns() + { + Spaces = new Dictionary() { + { "space-[A-Za-z0-9]", new PNTokenAuthValues() { Read = true } }} + }) + .ExecuteAsync(); + PNAccessManagerTokenResult grantTokenResult = grantTokenResponse.Result; + PNStatus grantTokenStatus = grantTokenResponse.Status; + if (!grantTokenStatus.Error && grantTokenResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(grantTokenStatus)); + } + // snippet.end + } + + static async Task RevokeTokenBasicUsage() + { + // snippet.revoke_token + PNResult revokeTokenResponse = await pubnub + .RevokeToken() + .Token("p0thisAkFl043rhDdHRsCkNDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI") + .ExecuteAsync(); + PNAccessManagerRevokeTokenResult revokeTokenResult = revokeTokenResponse.Result; + PNStatus revokeTokenStatus = revokeTokenResponse.Status; + if (!revokeTokenStatus.Error && revokeTokenResult != null) + { + Debug.Log("Revoke token success"); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(revokeTokenStatus)); + } + // snippet.end + } + + static async Task SetAuthTokenSnippet() + { + // snippet.set_token + pubnub.SetAuthToken( + "p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI"); + + // snippet.end + } + + static async Task ParseTokenBasicUsage() + { + // snippet.parse_token_usage + var parsedTokenContent = + pubnub.ParseToken( + "p0thisAkFl043rhDdHRsCkNyZXisRGNoYW6hanNlY3JldAFDZ3Jwsample3KgQ3NwY6BDcGF0pERjaGFuoENnctokenVzcqBDc3BjoERtZXRhoENzaWdYIGOAeTyWGJI"); + var parsedTokenJson = pubnub.JsonPluggableLibrary.SerializeToJsonString(parsedTokenContent); + // snippet.end + + /* + // snippet.parse_token_result + { + "Version":2, + "Timestamp":1619718521, + "TTL":15, + "AuthorizedUuid":"my_uuid", + "Resources":{ + "Uuids":{ + "uuid-id":{ + "Read":true, + "Write":true, + "Manage":true, + "Delete":true, + "Get":true, + "Update":true, + "Join":true + } + }, + "Channels":{ + "channel-id":{ + "Read":true, + "Write":true, + "Manage":true, + "Delete":true, + "Get":true, + "Update":true, + "Join":true + } + }, + "ChannelGroups":{ + "group-id":{ + "Read":true, + "Write":true, + "Manage":true, + "Delete":true, + "Get":true, + "Update":true, + "Join":true + } + } + }, + "Patterns":{ + "Uuids":{ + "uuid-pattern":{ + "Read":true, + "Write":true, + "Manage":true, + "Delete":true, + "Get":true, + "Update":true, + "Join":true + } + }, + "Channels":{ + "channel-pattern":{ + "Read":true, + "Write":true, + "Manage":true, + "Delete":true, + "Get":true, + "Update":true, + "Join":true + } + }, + "ChannelGroups":{ + "group-pattern":{ + "Read":true, + "Write":true, + "Manage":true, + "Delete":true, + "Get":true, + "Update":true, + "Join":true + } + } + } + } + // snippet.end + */ + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerSample.cs.meta b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerSample.cs.meta new file mode 100644 index 00000000..304af706 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 528743e1d6a2ade4ab32385c8f0e7dbb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerV2Sample.cs b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerV2Sample.cs new file mode 100644 index 00000000..4a2bd816 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerV2Sample.cs @@ -0,0 +1,247 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System.Threading.Tasks; + +public class AccessManagerV2Sample +{ + private static Pubnub pubnub; + + static void PubnubInit() + { + // snippet.pubnub_init + //Create configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo" + }; + //Create a new PubNub instance + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + static async Task Grant() + { + // snippet.grant + PNResult grantResponse = await pubnub.Grant() + .Channels(new string[]{ + //channels to allow grant on + "ch1", + "ch2", + "ch3" + }) + .ChannelGroups(new string[] { + // groups to allow grant on + "cg1", + "cg2", + "cg3" + }) + .AuthKeys(new string[] { + // the keys we are provisioning + "key1", + "key2", + "key3" + }) + .Write(true) // allow those keys to write (false by default) + .Manage(true) // allow those keys to manage channel groups (false by default) + .Read(true) // allow keys to read the subscribe feed (false by default) + .Delete(true) // allow those keys to delete the subscribe feed (false by default) + .TTL(12337) // how long those keys will remain valid (0 for eternity) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static void GrantCallback() + { + // snippet.grant_callback + pubnub.Grant() + .Channels(new string[]{ + //channels to allow grant on + "ch1", + "ch2", + "ch3" + }) + .ChannelGroups(new string[] { + // groups to allow grant on + "cg1", + "cg2", + "cg3" + }) + .AuthKeys(new string[] { + // the keys we are provisioning + "key1", + "key2", + "key3" + }) + .Write(true) // allow those keys to write (false by default) + .Manage(true) // allow those keys to manage channel groups (false by default) + .Read(true) // allow keys to read the subscribe feed (false by default) + .Delete(true) // allow those keys to delete the subscribe feed (false by default) + .TTL(12337) // how long those keys will remain valid (0 for eternity) + .Execute(new PNAccessManagerGrantResultExt( + (result, status) => { + //PNAccessManagerGrantResult is a parsed and abstracted response from server + } + )); + // snippet.end + } + + static async Task GrantTTL() + { + // snippet.grant_ttl + PNResult grantResponse = await pubnub.Grant() + .Channels(new string[] { + "my_channel" + }) + .Write(false) + .Read(true) + .Delete(false) + .AuthKeys(new string[] { + "my_ro_authkey" + }) + .TTL(5) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static async Task GrantPresence() + { + // snippet.grant_presence + PNResult grantResponse = await pubnub.Grant() + .Channels(new string[] { + "my_channel-pnpres" + }) + .Write(true) + .Read(true) + .Delete(true) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static async Task GrantChannelGroup() + { + // snippet.grant_group + PNResult grantResponse = await pubnub.Grant() + .ChannelGroups(new string[] { + "cg1", + "cg2", + "cg3" + }) + .AuthKeys(new string[] { + "key1", + "key2", + "key3" + }) + .Write(true) + .Manage(true) + .Read(true) + .Delete(true) + .TTL(12337) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static async Task GrantWithAuthKey() + { + // snippet.grant_auth_key + PNResult grantResponse = await pubnub.Grant() + .Uuids(new string[] { + "my_uuid" + }) + .Get(true) + .Update(true) + .Delete(true) + .AuthKeys(new string[] { + "my_ro_authkey" + }) + .TTL(1440) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static async Task GrantAppLevel() + { + // snippet.grant_app_level + PNResult grantResponse = await pubnub.Grant() + .Write(true) + .Read(true) + .Delete(true) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static async Task GrantChannelLevel() + { + // snippet.grant_channel_level + PNResult grantResponse = await pubnub.Grant() + .Channels(new string[] { + "my_channel" + }) + .Write(true) + .Read(true) + .Delete(true) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } + + static async Task GrantUserLevel() + { + // snippet.grant_user_level + PNResult grantResponse = await pubnub.Grant() + .Channels(new string[] { + "my_channel" + }) + .Write(true) + .Read(true) + .Delete(true) + .AuthKeys(new string[]{ + "my_authkey" + }) + .TTL(5) + .ExecuteAsync(); + + PNAccessManagerGrantResult grantResult = grantResponse.Result; + PNStatus status = grantResponse.Status; + //PNAccessManagerGrantResult is a parsed and abstracted response from server + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerV2Sample.cs.meta b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerV2Sample.cs.meta new file mode 100644 index 00000000..858907a6 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/AccessManager/AccessManagerV2Sample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b770e03dcd090c0468b165d82a53f790 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/AccessManager/GrantTokenExample.cs b/PubNubUnity/Assets/Snippets/AccessManager/GrantTokenExample.cs new file mode 100644 index 00000000..47677915 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/AccessManager/GrantTokenExample.cs @@ -0,0 +1,63 @@ +// snippet.grant_token_example +using System.Collections.Generic; +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class GrantTokenExample : MonoBehaviour { + //Reference to a pubnub manager previously setup in Unity Editor + //For more details see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + //NOTE: For Access Management to work the keyset must have PAM enabled + [SerializeField] private PNManagerBehaviour pubnubManager; + + //An editor-serialized string with the test channel ID + [SerializeField] private string testChannelId = "test_channel_id"; + + private async void Start() { + //Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + //Creating a full access set for the sake of demonstration + var fullAccess = new PNTokenAuthValues() { + Read = true, + Write = true, + Create = true, + Get = true, + Delete = true, + Join = true, + Update = true, + Manage = true + }; + + //Asynchronously executing a full-access grant operation for the test channel for user ID specified in the config + //The $"{testChannelId}{Constants.Pnpres}" addition ensured full access to the channel with PubNub Presence operations + var grantResult = await pubnub.GrantToken().TTL(30).AuthorizedUuid(pubnub.PNConfig.UserId).Resources( + new PNTokenResources() { + Channels = new Dictionary() { + { + testChannelId, fullAccess + }, + { + $"{testChannelId}{Constants.Pnpres}", fullAccess + } + } + }) + .ExecuteAsync(); + + //Doing simple error handling in case something went wrong during the grant operation + if (grantResult.Status.Error) { + Debug.LogError($"Error in grant operation: {grantResult.Status.ErrorData.Information}"); + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/AccessManager/GrantTokenExample.cs.meta b/PubNubUnity/Assets/Snippets/AccessManager/GrantTokenExample.cs.meta new file mode 100644 index 00000000..86282e7f --- /dev/null +++ b/PubNubUnity/Assets/Snippets/AccessManager/GrantTokenExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0946c8d7955244c7b23c905456d7e83c +timeCreated: 1751289480 \ No newline at end of file diff --git a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.xml.meta b/PubNubUnity/Assets/Snippets/ChannelGroup.meta similarity index 57% rename from PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.xml.meta rename to PubNubUnity/Assets/Snippets/ChannelGroup.meta index 278ce7bd..fecf9015 100644 --- a/PubNubUnity/Assets/PubNub/Runtime/Plugins/CBOR.xml.meta +++ b/PubNubUnity/Assets/Snippets/ChannelGroup.meta @@ -1,6 +1,7 @@ fileFormatVersion: 2 -guid: dfd01c5723faac04a9159478a0df2e05 -TextScriptImporter: +guid: ec2565c21e71cd84dbab4e6d343d515b +folderAsset: yes +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/PubNubUnity/Assets/Snippets/ChannelGroup/AddChannelsToGroupExample.cs b/PubNubUnity/Assets/Snippets/ChannelGroup/AddChannelsToGroupExample.cs new file mode 100644 index 00000000..a68914f3 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/ChannelGroup/AddChannelsToGroupExample.cs @@ -0,0 +1,45 @@ +// snippet.add_to_group +using PubnubApi.Unity; +using UnityEngine; + +public class AddChannelsToGroupExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + // An editor-serialized string for the channel group ID + [SerializeField] private string channelGroupId = "cg1"; + + // An editor-serialized array for the channels to add + [SerializeField] private string[] channelsToAdd = { "ch1", "ch2", "ch3" }; + + private async void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Adding channels to the specified channel group + var cgAddChResponse = await pubnub.AddChannelsToChannelGroup() + .ChannelGroup(channelGroupId) + .Channels(channelsToAdd) + .ExecuteAsync(); + + // Checking the status of the operation + var status = cgAddChResponse.Status; + if (status.Error) { + Debug.LogError($"Error adding channels to group: {status.ErrorData.Information}"); + } else { + Debug.Log($"Successfully added channels to group {channelGroupId}"); + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/ChannelGroup/AddChannelsToGroupExample.cs.meta b/PubNubUnity/Assets/Snippets/ChannelGroup/AddChannelsToGroupExample.cs.meta new file mode 100644 index 00000000..450d550f --- /dev/null +++ b/PubNubUnity/Assets/Snippets/ChannelGroup/AddChannelsToGroupExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 248969c7c72a4171b61cc08091457a8f +timeCreated: 1751289375 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/ChannelGroup/ChannelGroupsSample.cs b/PubNubUnity/Assets/Snippets/ChannelGroup/ChannelGroupsSample.cs new file mode 100644 index 00000000..e3f90fdb --- /dev/null +++ b/PubNubUnity/Assets/Snippets/ChannelGroup/ChannelGroupsSample.cs @@ -0,0 +1,63 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System.Threading.Tasks; + +public class ChannelGroupsSample +{ + private static Pubnub pubnub; + + static void PubnubInit() + { + // snippet.pubnub_init + //Create configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo" + }; + //Create a new PubNub instance + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + static async Task ListFromGroup() + { + // snippet.list + PNResult cgListChResponse = await pubnub.ListChannelsForChannelGroup() + .ChannelGroup("cg1") + .ExecuteAsync(); + // snippet.end + } + + static async Task RemoveFromGroup() + { + // snippet.remove + PNResult rmChFromCgResponse = await pubnub.RemoveChannelsFromChannelGroup() + .ChannelGroup("family") + .Channels(new string[] { + "son" + }) + .ExecuteAsync(); + // snippet.end + } + + static async Task DeleteGroup() + { + // snippet.delete + PNResult delCgResponse = await pubnub.DeleteChannelGroup() + .ChannelGroup("family") + .ExecuteAsync(); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/ChannelGroup/ChannelGroupsSample.cs.meta b/PubNubUnity/Assets/Snippets/ChannelGroup/ChannelGroupsSample.cs.meta new file mode 100644 index 00000000..29f96239 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/ChannelGroup/ChannelGroupsSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3f10a604345cc8c4f96f237517fb8d34 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Configuration.meta b/PubNubUnity/Assets/Snippets/Configuration.meta new file mode 100644 index 00000000..2e346d17 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Configuration.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f4bc54b604c637b4dab5d05fb45b6c5d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Configuration/ConfigurationSample.cs b/PubNubUnity/Assets/Snippets/Configuration/ConfigurationSample.cs new file mode 100644 index 00000000..116ba97e --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Configuration/ConfigurationSample.cs @@ -0,0 +1,183 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end + +// snippet.using_crypto +using PubnubApi.Security.Crypto; +using PubnubApi.Security.Crypto.Cryptors; +// snippet.end + +using System.Collections.Generic; + +public class ConfigurationSample +{ + private static Pubnub pubnub; + + static void PubnubInit() + { + // snippet.init_config + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + // snippet.end + + // snippet.crypto + // encrypts using 256-bit AES-CBC cipher (recommended) + // decrypts data encrypted with the legacy and the 256-bit AES-CBC ciphers + pnConfiguration.CryptoModule = new CryptoModule(new AesCbcCryptor("enigma"), + new List { new LegacyCryptor("enigma") }); + + // encrypts with 128-bit cipher key entropy (legacy) + // decrypts data encrypted with the legacy and the 256-bit AES-CBC ciphers + pnConfiguration.CryptoModule = new CryptoModule(new LegacyCryptor("enigma"), + new List { new AesCbcCryptor("enigma") }); + // snippet.end + + // snippet.new_pubnub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + static void VariousInitializations() { + PNConfiguration pnConfig = null; + { + // snippet.web_gl_init_one + var pubnub = new Pubnub(pnConfig, httpTransportService: new UnityWebGLHttpClientService(), + ipnsdkSource: new UnityPNSDKSource()); + // snippet.end + } + { + // snippet.web_gl_init_two + var pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfig, webGLBuildMode: true); + // snippet.end + } + } + + static void BasicUsage() + { + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", // Required + PublishKey = "demo", // Only required if publishing + SecretKey = "SecretKey", // Only required for access operations + Secure = true, // Enable SSL + AuthKey = "authKey", // If Access Manager is utilized + LogLevel = PubnubLogLevel.Debug, // Enable debugging + SubscribeTimeout = 310, // Subscribe loop timeout in seconds + NonSubscribeRequestTimeout = 300, // Non-subscribe request timeout + FilterExpression = "such=wow", // PSV2 filter expression + HeartbeatNotificationOption = PNHeartbeatNotificationOption.All, // Heartbeat notifications + PresenceTimeout = 120, // Presence timeout + }; + + // snippet.user_id + pnConfiguration.UserId = new UserId("myUserId"); + // snippet.end + + // snippet.get_user_id + UserId currentUserId = pubnub.GetCurrentUserId(); + // snippet.end + } + + static void ChangeUserId() + { + // snippet.change_user_id + //Setting the initial UserId + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + //Changing to a new UserId + pnConfiguration.UserId = new UserId("myUserId"); + // snippet.end + } + + static void SetAndGetAuthKey() + { + // snippet.set_auth_key + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.AuthKey = "authKey"; + // snippet.end + + // snippet.get_auth_key + string sampleAuthKey = pnConfiguration.AuthKey; + // snippet.end + } + + static void FilterExpression() + { + // snippet.filter_expression + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.FilterExpression = "such=wow"; + // snippet.end + + // snippet.get_filter_expression + string filterExpression = pnConfiguration.FilterExpression; + // snippet.end + } + + static void InitWithUUID() + { + // snippet.init_with_uuid + // Initialize PubNub using the configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Create the PubNub instance with the configuration + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + // snippet.end + } + + static void InitNonSecure() + { + // snippet.init_non_secure + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.PublishKey = "my_pubkey"; + pnConfiguration.SubscribeKey = "my_subkey"; + pnConfiguration.Secure = false; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + // snippet.end + } + + static void InitSecure() + { + // snippet.init_secure + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.PublishKey = "my_pubkey"; + pnConfiguration.SubscribeKey = "my_subkey"; + pnConfiguration.Secure = true; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + // snippet.end + } + + static void InitSecretKey() + { + // snippet.init_secret_key + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.PublishKey = "my_pubkey"; + pnConfiguration.SubscribeKey = "my_subkey"; + pnConfiguration.SecretKey = "my_secretkey"; + pnConfiguration.Secure = true; + + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + // snippet.end + } + + static void InitReadOnly() + { + // snippet.init_read_only + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.SubscribeKey = "my_subkey"; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Configuration/ConfigurationSample.cs.meta b/PubNubUnity/Assets/Snippets/Configuration/ConfigurationSample.cs.meta new file mode 100644 index 00000000..558388f5 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Configuration/ConfigurationSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 099b09c0af1f5ae42b467e6f6c0a3ede +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Configuration/PubnubConfigurationExample.cs b/PubNubUnity/Assets/Snippets/Configuration/PubnubConfigurationExample.cs new file mode 100644 index 00000000..8f561092 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Configuration/PubnubConfigurationExample.cs @@ -0,0 +1,51 @@ +// snippet.configuration_basic_usage +using System.Collections.Generic; +using PubnubApi; +using PubnubApi.Security.Crypto; +using PubnubApi.Security.Crypto.Cryptors; +using PubnubApi.Unity; +using UnityEngine; + +public class PubnubConfigurationExample : MonoBehaviour { + // Serialized fields to allow configuration within Unity Editor + [SerializeField] private string userId = "myUniqueUserId"; + [SerializeField] private string subscribeKey = "demo"; // Replace with your actual SubscribeKey + [SerializeField] private string publishKey = "demo"; // Replace with your actual PublishKey if publishing is needed + [SerializeField] private string secretKey = "yourSecretKey"; // Used if Access Manager operations are needed + [SerializeField] private string authKey = "authKey"; // Used if Access Manager is enabled + [SerializeField] private string filterExpression = "such=wow"; + [SerializeField] private bool useSSL = true; + [SerializeField] private bool logToUnityConsole = true; + + //Note that you can always use the PnConfigAsset Scriptable Object for setting these values in editor + [SerializeField] private PNConfigAsset configAsset; + + private void Start() { + // Initialize a PNConfiguration object with the provided values + PNConfiguration pnConfiguration = new PNConfiguration(new UserId(userId)) { + SubscribeKey = subscribeKey, + PublishKey = publishKey, + SecretKey = secretKey, + AuthKey = authKey, + Secure = useSSL, + CryptoModule = new CryptoModule(new AesCbcCryptor("enigma"), new List { new LegacyCryptor("enigma") }), + LogLevel = PubnubLogLevel.All, + SubscribeTimeout = 310, + NonSubscribeRequestTimeout = 300, + FilterExpression = filterExpression, + HeartbeatNotificationOption = PNHeartbeatNotificationOption.All + }; + + pnConfiguration.SetPresenceTimeoutWithCustomInterval(120, 59); + pnConfiguration.PresenceTimeout = 120; + + // Create a PubNub instance and perform Unity-specific setup + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration, unityLogging: logToUnityConsole); + + // Analogous setup with the Scriptable Object config: + Pubnub anotherPubnub = PubnubUnityUtils.NewUnityPubnub(configAsset); + + Debug.Log("PubNub configured and ready to use."); + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Configuration/PubnubConfigurationExample.cs.meta b/PubNubUnity/Assets/Snippets/Configuration/PubnubConfigurationExample.cs.meta new file mode 100644 index 00000000..25265f97 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Configuration/PubnubConfigurationExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 21eacb17228f45439c5ee3042bbdf16e +timeCreated: 1751288835 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Entities.meta b/PubNubUnity/Assets/Snippets/Entities.meta new file mode 100644 index 00000000..fead476d --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Entities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b7a43c20193a1a47ac9587cbb11c632 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Entities/EntitiesSample.cs b/PubNubUnity/Assets/Snippets/Entities/EntitiesSample.cs new file mode 100644 index 00000000..99099dd0 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Entities/EntitiesSample.cs @@ -0,0 +1,340 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; + +public class EntitiesSample +{ + private static Pubnub pubnub; + private static PNConfiguration config; + + static void Init() + { + // snippet.pubnub_init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static async Task GetUuidMetadataBasicUsage() + { + // snippet.get_uuid_metadata_basic_usage + // Get Metadata for UUID set in the pubnub instance + PNResult getUuidSetMetadataResponse = await pubnub.GetUuidMetadata() + .ExecuteAsync(); + PNGetUuidMetadataResult getUuidSetMetadataResult = getUuidSetMetadataResponse.Result; + PNStatus uuidSetStatus = getUuidSetMetadataResponse.Status; + + // Get Metadata for a specific UUID + PNResult getSpecificUuidMetadataResponse = await pubnub.GetUuidMetadata() + .Uuid("my-uuid") + .ExecuteAsync(); + PNGetUuidMetadataResult getSpecificUuidMetadataResult = getSpecificUuidMetadataResponse.Result; + PNStatus specificUuidStatus = getSpecificUuidMetadataResponse.Status; + // snippet.end + } + + public static async Task SetUuidMetadataBasicUsage() + { + // snippet.set_uuid_metadata_basic_usage + // Set Metadata for UUID set in the pubnub instance + PNResult setUuidMetadataResponse = await pubnub.SetUuidMetadata() + .Uuid(config.Uuid) + .Name("John Doe") + .Email("john.doe@user.com") + .ExecuteAsync(); + PNSetUuidMetadataResult setUuidMetadataResult = setUuidMetadataResponse.Result; + PNStatus status = setUuidMetadataResponse.Status; + // snippet.end + } + + public static async Task RemoveUuidMetadataBasicUsage() + { + // snippet.remove_uuid_metadata_basic_usage + // Remove Metadata for UUID set in the pubnub instance + PNResult removeUuidMetadataResponse = await pubnub.RemoveUuidMetadata() + .ExecuteAsync(); + PNRemoveUuidMetadataResult removeUuidMetadataResult = removeUuidMetadataResponse.Result; + PNStatus status = removeUuidMetadataResponse.Status; + // snippet.end + } + + public static async Task GetAllChannelMetadataBasicUsage() + { + // snippet.get_all_channel_metadata_basic_usage + PNResult getAllChannelMetadataResponse = await pubnub.GetAllChannelMetadata() + .IncludeCount(true) + .IncludeCustom(true) + .ExecuteAsync(); + + PNGetAllChannelMetadataResult getAllChannelMetadataResult = getAllChannelMetadataResponse.Result; + PNStatus status2 = getAllChannelMetadataResponse.Status; + // snippet.end + } + + public static async Task GetChannelMetadataBasicUsage() + { + // snippet.get_channel_metadata_basic_usage + // Get Metadata for a specific channel + PNResult getChannelMetadataResponse = await pubnub.GetChannelMetadata() + .Channel("my-channel") + .IncludeCustom(true) + .ExecuteAsync(); + + PNGetChannelMetadataResult getChannelMetadataResult = getChannelMetadataResponse.Result; + PNStatus status = getChannelMetadataResponse.Status; + // snippet.end + } + + public static async Task SetChannelMetadataBasicUsage() + { + // snippet.set_channel_metadata_basic_usage + // Set Metadata for a specific channel + PNResult setChannelMetadataResponse = await pubnub.SetChannelMetadata() + .Channel("my-channel") + .Name("John Doe") + .Description("sample description") + .Custom(new Dictionary() { { "color", "blue" } }) + .IncludeCustom(true) + .ExecuteAsync(); + + PNSetChannelMetadataResult setChannelMetadataResult = setChannelMetadataResponse.Result; + PNStatus status = setChannelMetadataResponse.Status; + // snippet.end + } + + public static async Task SetChannelMetadataIterativeUpdate() + { + // snippet.set_channel_metadata_iterative_update + PNConfiguration config = new PNConfiguration(new UserId("example")) + { + PublishKey = "demo", + SubscribeKey = "demo", + }; + Pubnub pubnub = new Pubnub(config); + string channel = "team.red"; + string name = "Red Team"; + string description = "The channel for Red team."; + var customField = new Dictionary() + { + { "visible", "team" }, + }; + PNResult setChannelMetadataResponse = await pubnub.SetChannelMetadata() + .Channel(channel) + .Name(name) + .Description(description) + .Custom(customField) + .ExecuteAsync(); + Debug.Log("The channel has been created with name and description.\n"); + + // Fetch current object with custom fields + PNResult currentObjectResponse = await pubnub.GetChannelMetadata() + .Channel(channel) + .IncludeCustom(true) + .ExecuteAsync(); + var currentObject = currentObjectResponse.Result; + + // Initialize the custom field dictionary + Dictionary custom = currentObject?.Custom ?? new Dictionary(); + + + // Add or update the field + custom["edit"] = "admin"; + + // Writing the updated object back to the server + try + { + setChannelMetadataResponse = await pubnub.SetChannelMetadata() + .Channel(channel) + .Custom(custom) + .Name(currentObject?.Name) + .Description(currentObject?.Description) + .ExecuteAsync(); + Debug.Log($"Object has been updated.\n {setChannelMetadataResponse.Result}"); + } + catch (Exception ex) + { + Debug.Log(ex.Message); + } + // snippet.end + } + + public static async Task RemoveChannelMetadataBasicUsage() + { + // snippet.remove_channel_metadata_basic_usage + // Delete Metadata for a specific channel + PNResult removeChannelMetadataResponse = await pubnub.RemoveChannelMetadata() + .Channel("mychannel") + .ExecuteAsync(); + + PNRemoveChannelMetadataResult removeChannelMetadataResult = removeChannelMetadataResponse.Result; + PNStatus status = removeChannelMetadataResponse.Status; + // snippet.end + } + + public static async Task GetMembershipsBasicUsage() + { + // snippet.get_memberships_basic_usage + PNResult getMembershipsResponse = await pubnub.GetMemberships() + .Uuid("my-uuid") + .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM }) + .IncludeCount(true) + .Page(new PNPageObject() { Next = "", Prev = "" }) + .ExecuteAsync(); + + PNMembershipsResult getMembeshipsResult = getMembershipsResponse.Result; + PNStatus status = getMembershipsResponse.Status; + // snippet.end + } + + public static async Task SetMembershipsBasicUsage() + { + // snippet.set_memberships_basic_usage + List setMembershipChannelMetadataIdList = + new() { + new PNMembership() + { Channel = "my-channel", Custom = new Dictionary() { { "item", "book" } } } + }; + + PNResult setMembershipsResponse = await pubnub.SetMemberships() + .Uuid("my-uuid") + .Channels(setMembershipChannelMetadataIdList) + .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM }) + .IncludeCount(true) + .ExecuteAsync(); + + PNMembershipsResult setMembershipsResult = setMembershipsResponse.Result; + PNStatus status = setMembershipsResponse.Status; + // snippet.end + } + + public static async Task RemoveMembershipsBasicUsage() + { + // snippet.remove_memberships_basic_usage + List removeMembershipList = + new() { + "my-channel", + "your-channel" + }; + + PNResult removeMembershipsResponse = await pubnub.RemoveMemberships() + .Uuid("uuid") + .Channels(removeMembershipList) + .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM }) + .IncludeCount(true) + .ExecuteAsync(); + + PNMembershipsResult removeMembershipsResult = removeMembershipsResponse.Result; + PNStatus status2 = removeMembershipsResponse.Status; + // snippet.end + } + + public static async Task ManageMembershipsBasicUsage() + { + // snippet.manage_memberships_basic_usage + List setMembrshipList = + new() { + new PNMembership() + { Channel = "ch1", Custom = new Dictionary() { { "say", "hello" } } }, + new PNMembership() + { Channel = "ch2", Custom = new Dictionary() { { "say", "world" } } }, + new PNMembership() { Channel = "ch3", Custom = new Dictionary() { { "say", "bye" } } } + }; + + List removeMembrshipList = new() { "ch4" }; + + PNResult manageMmbrshipsResponse = await pubnub.ManageMemberships() + .Uuid("my-uuid") + .Set(setMembrshipList) + .Remove(removeMembrshipList) + .Include(new PNMembershipField[] { PNMembershipField.CUSTOM, PNMembershipField.CHANNEL, PNMembershipField.CHANNEL_CUSTOM }) + .IncludeCount(true) + .Page(new PNPageObject() { Next = "", Prev = "" }) + .Sort(new List() { "channel.id:asc" }) + .ExecuteAsync(); + + PNMembershipsResult manageMmbrshipsResult = manageMmbrshipsResponse.Result; + PNStatus status = manageMmbrshipsResponse.Status; + // snippet.end + } + + public static async Task GetChannelMembersBasicUsage() + { + // snippet.get_channel_members_basic_usage + // Get Members (uuids) for a specific channel + PNResult getChannelMembersResponse = await pubnub.GetChannelMembers() + .Channel("my-channel") + .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM }) + .IncludeCount(true) + .ExecuteAsync(); + + PNChannelMembersResult getChannelMembersResult = getChannelMembersResponse.Result; + PNStatus status2 = getChannelMembersResponse.Status; + // snippet.end + } + + public static async Task SetChannelMembersBasicUsage() + { + // snippet.set_channel_members_basic_usage + // Add Members (UUID) for a specific channel + List setMemberChannelList = + new() { + new PNChannelMember() + { Uuid = "my-uuid", Custom = new Dictionary() { { "planet", "earth" } } } + }; + + PNResult setChannelMembersResponse = await pubnub.SetChannelMembers() + .Channel("my-channel") + .Uuids(setMemberChannelList) + .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM }) + .IncludeCount(true) + .ExecuteAsync(); + + PNChannelMembersResult setChannelMembersResult = setChannelMembersResponse.Result; + PNStatus status2 = setChannelMembersResponse.Status; + // snippet.end + } + + public static async Task RemoveChannelMembersBasicUsage() + { + // snippet.remove_channel_members_basic_usage + // Remove Members (UUID) for a specific channel + List removeChannelMemberList = + new() { + "my-uuid", + "your-uuid" + }; + + PNResult removeChannelMembersResponse = await pubnub.RemoveChannelMembers() + .Channel("my-channel") + .Uuids(removeChannelMemberList) + .Include(new PNChannelMemberField[] { PNChannelMemberField.CUSTOM, PNChannelMemberField.UUID, PNChannelMemberField.UUID_CUSTOM }) + .IncludeCount(true) + .ExecuteAsync(); + + PNChannelMembersResult removeChannelMembersResult = removeChannelMembersResponse.Result; + PNStatus status = removeChannelMembersResponse.Status; + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Entities/EntitiesSample.cs.meta b/PubNubUnity/Assets/Snippets/Entities/EntitiesSample.cs.meta new file mode 100644 index 00000000..68d06b9d --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Entities/EntitiesSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0d75b4d98bf06d84d9bbf8af5dd2cd0f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Entities/GetAllUuidMetadataExample.cs b/PubNubUnity/Assets/Snippets/Entities/GetAllUuidMetadataExample.cs new file mode 100644 index 00000000..17232794 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Entities/GetAllUuidMetadataExample.cs @@ -0,0 +1,51 @@ +// snippet.get_all_uuid_metadata_basic_usage +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class GetAllUuidMetadataExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + private async void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Fetching all UUID metadata + var getAllUuidMetadataResponse = await pubnub.GetAllUuidMetadata() + .IncludeCustom(true) + .IncludeCount(true) + .ExecuteAsync(); + + // Extracting the result and status + var getAllUuidMetadataResult = getAllUuidMetadataResponse.Result; + var status = getAllUuidMetadataResponse.Status; + + // Handling errors and logging results + if (status.Error) { + Debug.LogError($"Error fetching UUID metadata: {status.ErrorData.Information}"); + } else if (getAllUuidMetadataResult?.Uuids != null) { + Debug.Log("Successfully fetched UUID metadata:"); + foreach (var uuidMetadata in getAllUuidMetadataResult.Uuids) { + Debug.Log($"UUID: {uuidMetadata.Uuid}, Name: {uuidMetadata.Name}"); + if (uuidMetadata.Custom != null) { + foreach (var kvp in uuidMetadata.Custom) { + Debug.Log($"Custom Key: {kvp.Key}, Value: {kvp.Value}"); + } + } + } + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Entities/GetAllUuidMetadataExample.cs.meta b/PubNubUnity/Assets/Snippets/Entities/GetAllUuidMetadataExample.cs.meta new file mode 100644 index 00000000..5ad66937 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Entities/GetAllUuidMetadataExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 839bd11e849e4508b9a5ee74b71aba7b +timeCreated: 1751287801 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Files.meta b/PubNubUnity/Assets/Snippets/Files.meta new file mode 100644 index 00000000..757c2f9e --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Files.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e74ea101fed9654d88dea6578e8d690 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Files/FilesSample.cs b/PubNubUnity/Assets/Snippets/Files/FilesSample.cs new file mode 100644 index 00000000..59f39026 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Files/FilesSample.cs @@ -0,0 +1,141 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System.Threading.Tasks; +using UnityEngine; +using System; + +public class FilesSample +{ + private static Pubnub pubnub; + + static void InitSample() + { + // snippet.init + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static async Task ListFilesBasicUsage() + { + // snippet.list_files_basic_usage + PNResult listFilesResponse = await pubnub.ListFiles() + .Channel("my_channel") + .ExecuteAsync(); + PNListFilesResult listFilesResult = listFilesResponse.Result; + PNStatus listFilesStatus = listFilesResponse.Status; + if (!listFilesStatus.Error && listFilesResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(listFilesResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(listFilesStatus)); + } + // snippet.end + } + + public static async Task GetFileUrlBasicUsage() + { + // snippet.get_file_url_basic_usage + PNResult getFileUrlResponse = await pubnub.GetFileUrl() + .Channel("my_channel") + .FileId("d9515cb7-48a7-41a4-9284-f4bf331bc770") + .FileName("cat_picture.jpg") + .ExecuteAsync(); + PNFileUrlResult getFileUrlResult = getFileUrlResponse.Result; + PNStatus getFileUrlStatus = getFileUrlResponse.Status; + if (!getFileUrlStatus.Error && getFileUrlResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(getFileUrlResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(getFileUrlStatus)); + } + // snippet.end + } + + public static async Task DownloadFileBasicUsage(string downloadUrlFileName) + { + // snippet.download_file_basic_usage + PNResult fileDownloadResponse = await pubnub.DownloadFile() + .Channel("my_channel") + .FileId("d9515cb7-48a7-41a4-9284-f4bf331bc770") + .FileName("cat_picture.jpg") + .ExecuteAsync(); + PNDownloadFileResult fileDownloadResult = fileDownloadResponse.Result; + PNStatus fileDownloadStatus = fileDownloadResponse.Status; + if (!fileDownloadStatus.Error && fileDownloadResult != null) + { + fileDownloadResult.SaveFileToLocal(downloadUrlFileName); //saves to bin folder if no path is provided + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(fileDownloadResult.FileName)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(fileDownloadStatus)); + } + // snippet.end + } + + public static async Task DeleteFileBasicUsage() + { + // snippet.delete_file_basic_usage + PNResult deleteFileResponse = await pubnub.DeleteFile() + .Channel("my_channel") + .FileId("d9515cb7-48a7-41a4-9284-f4bf331bc770") + .FileName("cat_picture.jpg") + .ExecuteAsync(); + PNDeleteFileResult deleteFileResult = deleteFileResponse.Result; + PNStatus deleteFileStatus = deleteFileResponse.Status; + if (!deleteFileStatus.Error && deleteFileResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(deleteFileResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(deleteFileStatus)); + } + // snippet.end + } + + public static async Task PublishFileMessageBasicUsage() + { + // snippet.publish_file_message_basic_usage + PNResult publishFileMsgResponse = await pubnub.PublishFileMessage() + .Channel("my_channel") + .FileId("d9515cb7-48a7-41a4-9284-f4bf331bc770") + .FileName("cat_picture.jpg") //checks the bin folder if no path is provided + .Message("This is a sample message") + .CustomMessageType("file-message") + .ExecuteAsync(); + PNPublishFileMessageResult publishFileMsgResult = publishFileMsgResponse.Result; + PNStatus publishFileMsgStatus = publishFileMsgResponse.Status; + if (!publishFileMsgStatus.Error && publishFileMsgResult != null) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(publishFileMsgResult)); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(publishFileMsgStatus)); + } + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Files/FilesSample.cs.meta b/PubNubUnity/Assets/Snippets/Files/FilesSample.cs.meta new file mode 100644 index 00000000..bef22f79 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Files/FilesSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a255a4755cb51bb4086c03bdfe2abf74 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Files/SendFileExample.cs b/PubNubUnity/Assets/Snippets/Files/SendFileExample.cs new file mode 100644 index 00000000..01720ba0 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Files/SendFileExample.cs @@ -0,0 +1,55 @@ +// snippet.send_file_basic_usage +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class SendFileExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + // An editor-serialized string for the channel ID + [SerializeField] private string channelId = "my_channel"; + + // An editor-serialized string for the file path + [SerializeField] private string filePath = "cat_picture.jpg"; + + // An editor-serialized string for the cipher key + [SerializeField] private string cipherKey = "my_cipher_key"; + + private async void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Sending a file to the specified channel + var fileUploadResponse = await pubnub.SendFile() + .Channel(channelId) + .File(filePath) // checks the bin folder if no path is provided + .CipherKey(cipherKey) // Deprecated: Prefer setting up in PubNub config + .Message("Look at this photo!") + .CustomMessageType("file-message") + .ExecuteAsync(); + + // Extracting the result and status + var fileUploadResult = fileUploadResponse.Result; + var fileUploadStatus = fileUploadResponse.Status; + + // Handling errors and logging results + if (!fileUploadStatus.Error && fileUploadResult != null) { + Debug.Log($"File uploaded successfully: {pubnub.JsonPluggableLibrary.SerializeToJsonString(fileUploadResult)}"); + } else { + Debug.LogError($"Error uploading file: {pubnub.JsonPluggableLibrary.SerializeToJsonString(fileUploadStatus)}"); + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Files/SendFileExample.cs.meta b/PubNubUnity/Assets/Snippets/Files/SendFileExample.cs.meta new file mode 100644 index 00000000..b3f47c6d --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Files/SendFileExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 30b861d12d1349c48311cd8b632ab6b1 +timeCreated: 1751288575 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/GettingStarted.meta b/PubNubUnity/Assets/Snippets/GettingStarted.meta new file mode 100644 index 00000000..2705dce6 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/GettingStarted.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82b9c95bc2daddd49a3061d42fcd7db1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedExample.cs b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedExample.cs new file mode 100644 index 00000000..a1d4d563 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedExample.cs @@ -0,0 +1,51 @@ +// snippet.getting_started_full +using UnityEngine; +using PubnubApi; +using PubnubApi.Unity; + +public class PNManager : PNManagerBehaviour { + // UserId identifies this client. + public string userId; + + private async void Awake() { + if (string.IsNullOrEmpty(userId)) { + // It is recommended to change the UserId to a meaningful value to be able to identify this client. + userId = System.Guid.NewGuid().ToString(); + } + + // Listener example. + listener.onStatus += OnPnStatus; + listener.onMessage += OnPnMessage; + + // Initialize will create a PubNub instance, pass the configuration object, and prepare the listener. + Initialize(userId); + + // Modern API example + Channel channel = pubnub.Channel("TestChannel"); + Subscription subscription = channel.Subscription(); + subscription.Subscribe(); + + // Or legacy subscription example + // pubnub.Subscribe().Channels(new[] { "TestChannel" }).Execute(); + + // Publish example + await pubnub.Publish().Channel("TestChannel").Message("Hello World from Unity!").ExecuteAsync(); + } + + void OnPnStatus(Pubnub pn, PNStatus status) { + Debug.Log(status.Category == PNStatusCategory.PNConnectedCategory ? "Connected" : "Not connected"); + } + + void OnPnMessage(Pubnub pn, PNMessageResult result) { + Debug.Log($"Message received: {result.Message}"); + } + + protected override void OnDestroy() { + // Use OnDestroy to clean up, e.g. unsubscribe from listeners. + listener.onStatus -= OnPnStatus; + listener.onMessage -= OnPnMessage; + + base.OnDestroy(); + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedExample.cs.meta b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedExample.cs.meta new file mode 100644 index 00000000..4560c9b0 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedExample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e946e731600fa2c4b98ada7cf18aea31 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedSample.cs b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedSample.cs new file mode 100644 index 00000000..d82bfd4c --- /dev/null +++ b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedSample.cs @@ -0,0 +1,115 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +// snippet.end + +public class GettingStartedSample { + + private static Pubnub pubnub; + + static void Init() + { + // snippet.pubnub_init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + static void InitProgramatically() + { + // snippet.init_code + // Initialize PubNub using the configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Create the PubNub instance with the configuration + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // You can also initializa a "raw" pubnub instance but would have to then setup all Unity-specific functionality by yourself + Pubnub rawPubnub = new Pubnub(pnConfiguration); + // snippet.end + } + + static void AddListeners() { + PNManagerBehaviour pnManagerBehaviour = null; + + // snippet.add_listeners + // Get the listener from a PNManagerBehaviour: + var listener = pnManagerBehaviour.listener; + // Alternatively, create your own and add it to the Pubnub instance: + var createdListener = new SubscribeCallbackListener(); + pubnub.AddListener(createdListener); + + // Add callbacks + listener.onStatus += OnPnStatus; + listener.onMessage += OnPnMessage; + + // Status event handler + void OnPnStatus(Pubnub pn, PNStatus status) { + Debug.Log(status.Category == PNStatusCategory.PNConnectedCategory ? "Connected" : "Not connected"); + } + + // Message event handler + void OnPnMessage(Pubnub pn, PNMessageResult result) { + Debug.Log($"Message received: {result.Message}"); + } + // snippet.end + } + + static void CreateSubscription() { + // snippet.create_subscription + // Subscribe to a channel using modern API + Channel channel = pubnub.Channel("TestChannel"); + Subscription subscription = channel.Subscription(); + subscription.Subscribe(); + + // Or using the legacy API + pubnub.Subscribe().Channels(new[] { "TestChannel" }).Execute(); + // snippet.end + } + + static async void PublishMessages() { + Transform transform = null; + // snippet.publish_messages + // Publish a simple message + await pubnub.Publish().Channel("TestChannel").Message("Hello World from Unity!").ExecuteAsync(); + + // Publish a Unity object using the GetJsonSafe extension method for handling circular references + await pubnub.Publish().Channel("TestChannel").Message(transform.position.GetJsonSafe()).ExecuteAsync(); + + // Using a callback instead of async/await + pubnub.Publish() + .Channel("TestChannel") + .Message("Hello World from Unity!") + .Execute((result, status) => { + if (!status.Error) { + Debug.Log("Message sent successfully!"); + } else { + Debug.LogError("Failed to send message: " + status.ErrorData.Information); + } + }); + // snippet.end + } +} diff --git a/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedSample.cs.meta b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedSample.cs.meta new file mode 100644 index 00000000..9790c461 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/GettingStarted/GettingStartedSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 15c9087d7e872fa40a667a9742720cd7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Logging.meta b/PubNubUnity/Assets/Snippets/Logging.meta new file mode 100644 index 00000000..e12ac6a7 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Logging.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5eced3c72c03e0c4b8f7c3281ffe26d6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs new file mode 100644 index 00000000..ce0b0179 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs @@ -0,0 +1,57 @@ +// snippet.using +using PubnubApi; + +// snippet.end +using System; +using System.Globalization; + +public class LoggingSample +{ + // snippet.custom_logger + // A custom logger that logs information on Unity console. + // Use can implement logger that can log information using log4Net or file etc. + // You can find a default Unity-specific logger in UnityPubNubLogger.cs + public class PubnubUnityConsoleLoggerExample : IPubnubLogger { + public void Trace(string traceLog) => + UnityEngine.Debug.Log($"[{DateTime.Now.ToString(CultureInfo.InvariantCulture)}] [TRACE] {traceLog}"); + + public void Debug(string debugLog) => + UnityEngine.Debug.Log($"[{DateTime.Now.ToString(CultureInfo.InvariantCulture)}] [DEBUG] {debugLog}"); + + public void Info(string infoLog) => + UnityEngine.Debug.Log($"[{DateTime.Now.ToString(CultureInfo.InvariantCulture)}] [INFO] {infoLog}"); + + public void Warn(string warningLog) => + UnityEngine.Debug.LogWarning($"[{DateTime.Now.ToString(CultureInfo.InvariantCulture)}] [WARN] {warningLog}"); + + public void Error(string errorLog) => + UnityEngine.Debug.LogError($"[{DateTime.Now.ToString(CultureInfo.InvariantCulture)}] [ERROR] {errorLog}"); + } + // snippet.end + + public static void EnableLogging() + { + // snippet.enable_logging + var pubnubConfiguration = new PNConfiguration(new UserId("uniqueUserId")) + { + SubscribeKey = "[yourSubscribeKey]", + PublishKey = "[yourPublishKey]", + LogLevel = PubnubLogLevel.Debug, + }; + var pubnub = new Pubnub(pubnubConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + var customLogger = new PubnubUnityConsoleLoggerExample(); + pubnub.SetLogger(customLogger); + + // To remove the custom logger. Use RemoveLogger(). + pubnub.RemoveLogger(customLogger); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs.meta b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs.meta new file mode 100644 index 00000000..f8c3818b --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 39f1af75d2ce28346b57d04ccf829bc0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/MessageActions.meta b/PubNubUnity/Assets/Snippets/MessageActions.meta new file mode 100644 index 00000000..f06995af --- /dev/null +++ b/PubNubUnity/Assets/Snippets/MessageActions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dd39201ec6149574c819571433311b56 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/MessageActions/AddMessageActionExample.cs b/PubNubUnity/Assets/Snippets/MessageActions/AddMessageActionExample.cs new file mode 100644 index 00000000..cd8ff971 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/MessageActions/AddMessageActionExample.cs @@ -0,0 +1,46 @@ +// snippet.add_message_action_basic_usage +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class AddMessageActionExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + // An editor-serialized string for the channel ID + [SerializeField] private string channelId = "my_channel"; + + // An editor-serialized timetoken for the message + [SerializeField] private long messageTimetoken = 5610547826969050; + + private void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Adding a message action (reaction) to a specified message + pubnub.AddMessageAction() + .Channel(channelId) + .MessageTimetoken(messageTimetoken) + .Action(new PNMessageAction { Type = "reaction", Value = "smiley_face" }) + .Execute((result, status) => { + // Handling the result of the operation + if (status.Error) { + Debug.LogError($"Error adding message action: {status.ErrorData.Information}"); + } else { + Debug.Log($"Successfully added message action: {pubnub.JsonPluggableLibrary.SerializeToJsonString(result)}"); + } + }); + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/MessageActions/AddMessageActionExample.cs.meta b/PubNubUnity/Assets/Snippets/MessageActions/AddMessageActionExample.cs.meta new file mode 100644 index 00000000..41012bb4 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/MessageActions/AddMessageActionExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 11419223532b4d31ad960b629af6bef7 +timeCreated: 1751288487 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/MessageActions/MessageActionsSample.cs b/PubNubUnity/Assets/Snippets/MessageActions/MessageActionsSample.cs new file mode 100644 index 00000000..4a8c6d7b --- /dev/null +++ b/PubNubUnity/Assets/Snippets/MessageActions/MessageActionsSample.cs @@ -0,0 +1,63 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using UnityEngine; +using System; + +public class MessageActionsSample +{ + private static Pubnub pubnub; + + static void Init() + { + // snippet.init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static void RemoveMessageActionBasicUsage() + { + // snippet.remove_message_action_basic_usage + pubnub.RemoveMessageAction() + .Channel("my_channel") + .MessageTimetoken(15701761818730000) + .ActionTimetoken(15701775691010000) + .Uuid("mytestuuid") + .Execute(new PNRemoveMessageActionResultExt((result, status) => + { + //empty result of type PNRemoveMessageActionResult. + })); + // snippet.end + } + + public static void GetMessageActionsBasicUsage() + { + // snippet.get_message_actions_basic_usage + pubnub.GetMessageActions() + .Channel("my_channel") + .Execute(new PNGetMessageActionsResultExt((result, status) => + { + //result is of type PNGetMessageActionsResult. + })); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/MessageActions/MessageActionsSample.cs.meta b/PubNubUnity/Assets/Snippets/MessageActions/MessageActionsSample.cs.meta new file mode 100644 index 00000000..89e9bcc5 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/MessageActions/MessageActionsSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7a4c574312ea9b14e9cca673bca2a356 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Misc.meta b/PubNubUnity/Assets/Snippets/Misc.meta new file mode 100644 index 00000000..3b13817a --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Misc.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6fad00bea1e423749a386b42d77f4d72 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Misc/MiscSample.cs b/PubNubUnity/Assets/Snippets/Misc/MiscSample.cs new file mode 100644 index 00000000..384ff04f --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Misc/MiscSample.cs @@ -0,0 +1,133 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System.Collections.Generic; +using UnityEngine; + +public class MiscSample +{ + private static Pubnub pubnub; + + static void Init() + { + // snippet.init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static void EncryptBasicUsage() + { + // snippet.encrypt_basic_usage + string stringToEncrypt = "hello world"; + var crypto = PubnubApi.Security.Crypto.CryptoModule.CreateAesCbcCryptor("test"); + crypto.Encrypt(stringToEncrypt); + // snippet.end + } + + public static void EncryptFileBasicUsage() + { + // snippet.encrypt_file_basic_usage + string source_file = "cat_picture.jpg"; // checks bin folder if no path is provided + string destination_file = "destination_cat_pic.jpg"; // checks bin folder if no path is provided + var crypto = PubnubApi.Security.Crypto.CryptoModule.CreateAesCbcCryptor("test"); + crypto.EncryptFile(source_file, destination_file); + // snippet.end + } + + public static void EncryptFileBytesBasicUsage() + { + // snippet.encrypt_file_bytes_basic_usage + byte[] sourceBytes = System.IO.File.ReadAllBytes("cat_picture.jpg"); // checks bin folder if no path is provided + var crypto = PubnubApi.Security.Crypto.CryptoModule.CreateAesCbcCryptor("test"); + byte[] outputBytes = crypto.Encrypt(sourceBytes); + System.IO.File.WriteAllBytes("destination_cat_pic.jpg", outputBytes); // checks bin folder if no path is provided + // snippet.end + } + + public static void DecryptBasicUsage() + { + // snippet.decrypt_basic_usage + var crypto = PubnubApi.Security.Crypto.CryptoModule.CreateAesCbcCryptor("test"); + crypto.Decrypt("encryptedString"); + // snippet.end + } + + public static void DecryptFileBasicUsage() + { + // snippet.decrypt_file_basic_usage + string source_file = "encrypted_cat_pic.jpg"; // checks bin folder if no path is provided + string destination_file = "cat_pic_original.jpg"; // checks bin folder if no path is provided + var crypto = PubnubApi.Security.Crypto.CryptoModule.CreateAesCbcCryptor("test"); + crypto.DecryptFile(source_file, destination_file); + // snippet.end + } + + public static void DecryptFileBytesBasicUsage() + { + // snippet.decrypt_file_bytes_basic_usage + byte[] sourceBytes = System.IO.File.ReadAllBytes("encrypted_cat_pic.jpg"); // checks bin folder if no path is provided + var crypto = PubnubApi.Security.Crypto.CryptoModule.CreateAesCbcCryptor("test"); + byte[] outputBytes = crypto.Decrypt(sourceBytes); + System.IO.File.WriteAllBytes("cat_pic_original.jpg", outputBytes); // checks bin folder if no path is provided + // snippet.end + } + + public static void DisconnectBasicUsage() + { + // snippet.disconnect_basic_usage + pubnub.Disconnect(); + // snippet.end + } + + public static void GetSubscribedChannelGroupsBasicUsage() + { + // snippet.get_subscribed_channel_groups_basic_usage + List groups = pubnub.GetSubscribedChannelGroups(); + // snippet.end + } + + public static void GetSubscribedChannelsBasicUsage() + { + // snippet.get_subscribed_channels_basic_usage + List channels = pubnub.GetSubscribedChannels(); + // snippet.end + } + + public static void ReconnectBasicUsage() + { + // snippet.reconnect_basic_usage + pubnub.Reconnect(); + // snippet.end + } + + public static void TimeBasicUsage() + { + // snippet.time_basic_usage + pubnub.Time() + .Execute(new PNTimeResultExt( + (result, status) => { + // handle time result. + } + )); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Misc/MiscSample.cs.meta b/PubNubUnity/Assets/Snippets/Misc/MiscSample.cs.meta new file mode 100644 index 00000000..b31146f2 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Misc/MiscSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ed74207c8347fc8458e9731bf44ba184 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Misc/PubnubCleanupExample.cs b/PubNubUnity/Assets/Snippets/Misc/PubnubCleanupExample.cs new file mode 100644 index 00000000..eb638290 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Misc/PubnubCleanupExample.cs @@ -0,0 +1,13 @@ +// snippet.cleanup_basic_usage +using PubnubApi; +using UnityEngine; + +public class PubnubCleanupExample : MonoBehaviour { + private void OnApplicationQuit() { + // Performing cleanup operations + Debug.Log("Cleaning up PubNub resources..."); + Pubnub.CleanUp(); + Debug.Log("Cleanup complete."); + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Misc/PubnubCleanupExample.cs.meta b/PubNubUnity/Assets/Snippets/Misc/PubnubCleanupExample.cs.meta new file mode 100644 index 00000000..c14f550c --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Misc/PubnubCleanupExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3dff4c9bc0b141cab2d5ce06a9df88af +timeCreated: 1751288283 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Presence.meta b/PubNubUnity/Assets/Snippets/Presence.meta new file mode 100644 index 00000000..5b8f404d --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Presence.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d88b70744e9d784eb7af1d98961b0df +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Presence/HereNowExample.cs b/PubNubUnity/Assets/Snippets/Presence/HereNowExample.cs new file mode 100644 index 00000000..bd467525 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Presence/HereNowExample.cs @@ -0,0 +1,65 @@ +// snippet.here_now_basic_usage +using System.Collections.Generic; +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class HereNowExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + // An editor-serialized array with test channel IDs + [SerializeField] private string[] testChannelIds = { "coolChannel", "coolChannel2" }; + + private async void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Executing the HereNow operation to get a list of UUIDs subscribed to channels + var herenowResponse = await pubnub.HereNow() + .Channels(testChannelIds) + .IncludeUUIDs(true) + .ExecuteAsync(); + + // Result and status of the HereNow operation + var herenowResult = herenowResponse.Result; + var status = herenowResponse.Status; + + // Handling potential errors + if (status.Error) { + Debug.LogError($"Error in HereNow operation: {status.ErrorData.Information}"); + } else { + if (herenowResult?.Channels != null && herenowResult.Channels.Count > 0) { + foreach (KeyValuePair kvp in herenowResult.Channels) { + PNHereNowChannelData channelData = kvp.Value; + + Debug.Log("---"); + Debug.Log($"channel: {channelData.ChannelName}"); + Debug.Log($"occupancy: {channelData.Occupancy}"); + Debug.Log("Occupants:"); + + if (channelData.Occupants != null && channelData.Occupants.Count > 0) { + foreach (var occupant in channelData.Occupants) { + Debug.Log($"uuid: {occupant.Uuid}"); + Debug.Log($"state: {(occupant.State != null ? pubnub.JsonPluggableLibrary.SerializeToJsonString(occupant.State) : "No state")}"); + } + } + } + } else { + Debug.Log("No occupants found."); + } + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Presence/HereNowExample.cs.meta b/PubNubUnity/Assets/Snippets/Presence/HereNowExample.cs.meta new file mode 100644 index 00000000..a0216c3a --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Presence/HereNowExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: be9ff8d463f9417594b27022c93055d0 +timeCreated: 1751287483 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Presence/PresenceSample.cs b/PubNubUnity/Assets/Snippets/Presence/PresenceSample.cs new file mode 100644 index 00000000..501f2df5 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Presence/PresenceSample.cs @@ -0,0 +1,273 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; +using System; + +public class PresenceSample +{ + private static Pubnub pubnub; + + static void Init() + { + // snippet.pubnub_init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static void HereNowSynchronous() + { + // snippet.here_now_synchronous + pubnub.HereNow() + // tailor the next two lines to example + .Channels(new string[] { + "coolChannel", + "coolChannel2" + }) + .IncludeUUIDs(true) + .Execute(new PNHereNowResultEx( + (result, status) => { + if (status.Error) { + // handle error + return; + } + + if (result.Channels != null && result.Channels.Count > 0) { + foreach (KeyValuePair kvp in result.Channels) { + PNHereNowChannelData channelData = kvp.Value; + Debug.Log("---"); + Debug.Log("channel:" + channelData.ChannelName); + Debug.Log("occupancy:" + channelData.Occupancy); + Debug.Log("Occupants:"); + if (channelData.Occupants != null && channelData.Occupants.Count > 0) { + for (int index = 0; index < channelData.Occupants.Count; index++) { + PNHereNowOccupantData occupant = channelData.Occupants[index]; + Debug.Log(string.Format("uuid: {0}", occupant.Uuid)); + Debug.Log(string.Format("state:{1}", (occupant.State != null) ? + pubnub.JsonPluggableLibrary.SerializeToJsonString(occupant.State) : "")); + } + } + } + } + } + )); + // snippet.end + } + + public static async Task HereNowReturningState() + { + // snippet.here_now_returning_state + PNResult herenowResponse = await pubnub.HereNow() + .Channels(new string[] { + // who is present on those channels? + "my_channel" + }) + .IncludeState(true) // include state with request (false by default) + .IncludeUUIDs(true) // if false, only shows occupancy count + .ExecuteAsync(); + + PNHereNowResult herenowResult = herenowResponse.Result; + PNStatus status = herenowResponse.Status; + //handle it + // snippet.end + } + + public static async Task HereNowReturnOccupancyOnly() + { + // snippet.here_now_return_occupancy_only + PNResult herenowResponse = await pubnub.HereNow() + .Channels(new string[] { + // who is present on those channels? + "my_channel" + }) + .IncludeState(false) // include state with request (false by default) + .IncludeUUIDs(false) // if false, only shows occupancy count + .ExecuteAsync(); + + PNHereNowResult herenowResult = herenowResponse.Result; + PNStatus status = herenowResponse.Status; + //handle it + // snippet.end + } + + public static async Task WhereNowBasicUsage() + { + // snippet.where_now_basic_usage + PNResult wherenowResponse = await pubnub.WhereNow() + .ExecuteAsync(); + + PNWhereNowResult wherenowResult = wherenowResponse.Result; + PNStatus status = wherenowResponse.Status; + // returns a pojo with channels + // channel groups which I am part of. + // snippet.end + } + + public static void WhereNowSynchronous() + { + // snippet.where_now_synchronous + pubnub.WhereNow() + .Execute(new PNWhereNowResultExt( + (result, status) => { + // returns a pojo with channels + // channel groups which I am part of. + } + )); + // snippet.end + } + + public static async Task WhereNowOtherUuid() + { + // snippet.where_now_other_uuid + PNResult wherenowResponse = await pubnub.WhereNow() + .Uuid("some-other-uuid") // uuid of the user we want to spy on. + .ExecuteAsync(); + + PNWhereNowResult wherenowResult = wherenowResponse.Result; + PNStatus status = wherenowResponse.Status; + // returns a pojo with channels + // channel groups which "some-other-uuid" part of.ere_now_example_1 + // snippet.end + } + + public static async Task SetPresenceStateBasicUsage() + { + // snippet.set_presence_state_basic_usage + Dictionary myState = new Dictionary(); + myState.Add("age", 20); + + PNResult setstateResponse = await pubnub.SetPresenceState() + .Channels(new string[] { + "ch1", + "ch2", + "ch3" + }) + .State(myState) + .ExecuteAsync(); + + PNSetStateResult setstateResult = setstateResponse.Result; + PNStatus status = setstateResponse.Status; + // handle set state response + // snippet.end + } + + public static async Task GetPresenceStateBasicUsage() + { + // snippet.get_presence_state_basic_usage + PNResult getstateResponse = await pubnub.GetPresenceState() + .Channels(new string[] { + // channels to fetch state for + "ch1", + "ch2", + "ch3" + }) + .ChannelGroups(new string[] { + // channel groups to fetch state for + "cg1", + "cg2", + "cg3" + }) + .Uuid("suchUUID") // uuid of user to fetch, or for own uuid + .ExecuteAsync(); + + PNGetStateResult getstateResult = getstateResponse.Result; + PNStatus status = getstateResponse.Status; + // handle response + // snippet.end + } + + public static void SetPresenceStateSynchronous() + { + // snippet.set_presence_state_synchronous + Dictionary myState = new Dictionary(); + myState.Add("age", 20); + + pubnub.SetPresenceState() + .Channels(new string[] { + "ch1", + "ch2", + "ch3" + }) + .State(myState) + .Execute(new PNSetStateResultExt( + (result, status) => { + // handle set state response + } + )); + // snippet.end + } + + public static void GetPresenceStateSynchronous() + { + // snippet.get_presence_state_synchronous + pubnub.GetPresenceState() + .Channels(new string[] { + // channels to fetch state for + "ch1", + "ch2", + "ch3" + }) + .ChannelGroups(new string[] { + // channel groups to fetch state for + "cg1", + "cg2", + "cg3" + }) + .Uuid("suchUUID") // uuid of user to fetch, or for own uuid + .Execute(new PNGetStateResultExt( + (result, status) => { + // handle response + } + )); + // snippet.end + } + + public static async Task SetPresenceStateForChannelGroups() + { + // snippet.set_presence_state_for_channel_groups + Dictionary myState = new Dictionary(); + myState.Add("age", 20); + + PNResult setstateResponse = await pubnub.SetPresenceState() + .ChannelGroups(new string[] { + // apply on those channel groups + "cg1", + "cg2", + "cg3" + }) + .Channels(new string[] { + // apply on those channels + "ch1", + "ch2", + "ch3" + }) + .State(myState) // the new state + .ExecuteAsync(); + + PNSetStateResult setstateResult = setstateResponse.Result; + PNStatus status = setstateResponse.Status; + // on new state for those channels + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Presence/PresenceSample.cs.meta b/PubNubUnity/Assets/Snippets/Presence/PresenceSample.cs.meta new file mode 100644 index 00000000..1b234d87 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Presence/PresenceSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 519c0e5dbecdc7a478be01cac813f584 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Publish.meta b/PubNubUnity/Assets/Snippets/Publish.meta new file mode 100644 index 00000000..7bfaaedd --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Publish.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a625ba849a1a850429794d40ffd21c82 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Publish/PublishSubscribeSample.cs b/PubNubUnity/Assets/Snippets/Publish/PublishSubscribeSample.cs new file mode 100644 index 00000000..329ab04a --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Publish/PublishSubscribeSample.cs @@ -0,0 +1,963 @@ +// snippet.using +using PubnubApi; + +// snippet.end +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; +using System; +using System.Linq; +using PubnubApi.Unity; + +public class PublishSubscribeSample +{ + private static Pubnub pubnub; + + static void Init() + { + // snippet.pubnub_init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static async Task PublishBasicUsage() + { + // snippet.publish_basic_usage + try + { + // Publishing a message to a channel + Dictionary position = new Dictionary + { + { "lat", 32F }, + { "lng", 32F } + }; + + Debug.Log("before pub: " + pubnub.JsonPluggableLibrary.SerializeToJsonString(position)); + + PNResult publishResponse = await pubnub.Publish() + .Message(position) + .Channel("my_channel") + .CustomMessageType("text-message") + .ExecuteAsync(); + + PNPublishResult publishResult = publishResponse.Result; + PNStatus status = publishResponse.Status; + + if (!status.Error) + { + Debug.Log("pub timetoken: " + publishResult.Timetoken.ToString()); + Debug.Log("pub status code : " + status.StatusCode.ToString()); + } + else + { + Debug.LogError("Error occurred: " + pubnub.JsonPluggableLibrary.SerializeToJsonString(status)); + } + } + catch (Exception ex) + { + Debug.LogError($"Request cannot be executed due to error: {ex.Message}"); + } + // snippet.end + } + + public static void PublishSynchronous() + { + // snippet.publish_synchronous + //Publishing Dictionary + Dictionary position = new Dictionary(); + position.Add("lat", 32F); + position.Add("lng", 32F); + + Debug.Log("before pub: " + pubnub.JsonPluggableLibrary.SerializeToJsonString(position)); + + pubnub.Publish() + .Message(position) + .Channel("my_channel") + .CustomMessageType("text-message") + .Execute(new PNPublishResultExt( + (result, status) => + { + Debug.Log("pub timetoken: " + result.Timetoken.ToString()); + Debug.Log("pub status code : " + status.StatusCode.ToString()); + } + )); + // snippet.end + } + + public static void PublishWithMetadata() + { + // snippet.publish_with_metadata + string[] arrayMessage = new string[] + { + "hello", + "there" + }; + + pubnub.Publish() + .Message(arrayMessage.ToList()) + .Channel("suchChannel") + .ShouldStore(true) + .Meta(new Dictionary() { { "someKey", "someValue" } }) + .UsePOST(true) + .CustomMessageType("text-message") + .Execute(new PNPublishResultExt( + (result, status) => + { + // handle publish result, status always present, result if successful + // status.Error to see if error happened + } + )); + // snippet.end + } + + public static async Task PublishStoreForHours() + { + // snippet.publish_store_for_hours + var publishResult = await pubnub.Publish() + .Channel("coolChannel") + .Message("test") + .ShouldStore(true) + .Ttl(10) + .ExecuteAsync(); + // snippet.end + } + + // snippet.publish_mobile_payload + + public class MobilePayload + { + public Dictionary pn_apns; + public Dictionary pn_gcm; + public Dictionary full_game; + } + + public static void PublishMobilePayload() + { + Dictionary apnsData = new Dictionary(); + apnsData.Add("aps", new Dictionary() + { + { "alert", "Game update 49ers touchdown" }, + { "badge", 2 } + }); + apnsData.Add("teams", new string[] { "49ers", "raiders" }); + apnsData.Add("score", new int[] { 7, 0 }); + + Dictionary gcmData = new Dictionary(); + gcmData.Add("data", new Dictionary() + { + { + "summary", "Game update 49ers touchdown" + }, + { + "teams", new string[] { "49ers", "raiders" } + }, + { + "score", new int[] { 7, 0 } + }, + { + "lastplay", "5yd run up the middle" + }, + }); + + MobilePayload mobilePayload = new MobilePayload(); + mobilePayload.pn_apns = apnsData; + mobilePayload.pn_gcm = gcmData; + mobilePayload.full_game = new Dictionary() + { + { "date", "2014.05.20" }, + { "foobar", "Data that is not pertinent to devices" } + }; + + pubnub.Publish() + .Message(mobilePayload) + .Channel("my_channel") + .ShouldStore(true) + .CustomMessageType("text-message") + .Execute(new PNPublishResultExt( + (result, status) => + { + // Check whether request successfully completed or not. + if (status.Error) + { + // something bad happened. + Debug.Log( + $"error while publishing: {pubnub.JsonPluggableLibrary.SerializeToJsonString(status)}"); + } + else + { + Debug.Log($"published with timetoken: {result.Timetoken}"); + } + } + )); + } + // snippet.end + + public static void FireBasicUsage() + { + // snippet.fire_basic_usage + string[] arrMessage = new string[] + { + "hello", + "there" + }; + + pubnub.Fire() + .Message(arrMessage.ToList()) + .Channel("my-channel") + .UsePOST(true) + .Execute(new PNPublishResultExt( + (result, status) => + { + if (status.Error) + { + Debug.Log( + $"error while publishing: {pubnub.JsonPluggableLibrary.SerializeToJsonString(status)}"); + } + else + { + Debug.Log($"published with timetoken: {result.Timetoken}"); + } + } + )); + // snippet.end + } + + public static void SignalBasicUsage() + { + // snippet.signal_basic_usage + Dictionary myMessage = new Dictionary(); + myMessage.Add("msg", "Hello Signals"); + + pubnub.Signal() + .Message(myMessage) + .Channel("foo") + .CustomMessageType("text-message") + .Execute(new PNPublishResultExt((result, status) => + { + if (status.Error) + { + Debug.Log(status.ErrorData.Information); + } + else + { + Debug.Log(result.Timetoken); + } + })); + // snippet.end + } + + public static void SubscribeBasicUsage() + { + // snippet.subscribe_basic_usage + pubnub.Subscribe() + .Channels(new string[] + { + // subscribe to channels + "my_channel" + }) + .Execute(); + // snippet.end + } + + public static void SubscribeNewBasicUsage() + { + // snippet.subscribe_basic_usage_new + Subscription subscription1 = pubnub.Channel("channelName").Subscription(); + subscription1.Subscribe(); + + SubscriptionSet subscriptionSet = pubnub.SubscriptionSet( + new string[] { "channel1", "channel2" }, + new string[] { "channel_group_1", "channel_group_2" }, + SubscriptionOptions.ReceivePresenceEvents + ); + + subscriptionSet.Subscribe(); + // snippet.end + } + + public static void SubscribeWithLogging() + { + // snippet.subscribe_with_logging + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + // subscribeKey from admin panel + SubscribeKey = "my_subkey", // required + // publishKey from admin panel (only required if publishing) + PublishKey = "my_pubkey", + // logging level declaration + LogLevel = PubnubLogLevel.Debug + }; + + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + pubnub.Subscribe() + .Channels(new string[] + { + // subscribe to channels + "my_channel" + }) + .Execute(); + // snippet.end + } + + public static void SubscribeMultipleChannels() + { + // snippet.subscribe_multiple_channels + pubnub.Subscribe() + .Channels(new string[] + { + // subscribe to channels information + "my_channel1", + "my_channel2" + }) + .Execute(); + // snippet.end + } + + public static void SubscribeWithPresence() + { + // snippet.subscribe_with_presence + pubnub.Subscribe() + .Channels(new string[] + { + // subscribe to channels + "my_channel" + }) + .WithPresence() // also subscribe to related presence information + .Execute(); + // snippet.end + } + + public static void SubscribeWithState() + { + // snippet.subscribe_with_state + var listener = new SubscribeCallbackListener(); + listener.onStatus += (pubnubObj, status) => + { + if (status.Category == PNStatusCategory.PNConnectedCategory) + { + Dictionary data = new Dictionary(); + data.Add("FieldA", "Awesome"); + data.Add("FieldB", 10); + + pubnub.SetPresenceState() + .Channels(new string[] { "awesomeChannel" }) + .ChannelGroups(new string[] { "awesomeChannelGroup" }) + .State(data) + .Execute(new PNSetStateResultExt( + (r, s) => + { + // handle set state response + } + )); + } + }; + pubnub.AddListener(listener); + + pubnub.Subscribe() + .Channels(new string[] + { + "awesomeChannel" + }) + .Execute(); + // snippet.end + } + + public static void SubscribeChannelGroup() + { + // snippet.subscribe_channel_group + pubnub.Subscribe() + .Channels(new string[] + { + // subscribe to channels + "ch1", + "ch2" + }) + .ChannelGroups(new string[] + { + // subscribe to channel groups + "cg1", + "cg2" + }) + .WithTimetoken(1337L) // optional, pass a timetoken + .WithPresence() // also subscribe to related presence information + .Execute(); + // snippet.end + } + + public static void SubscribeChannelGroupPresence() + { + // snippet.subscribe_channel_group_presence + pubnub.Subscribe() + .ChannelGroups(new string[] + { + // subscribe to channel groups + "cg1", + "cg2" + }) + .WithTimetoken(1337L) // optional, pass a timetoken + .WithPresence() // also subscribe to related presence information + .Execute(); + // snippet.end + } + + // snippet.subscribe_custom_type + public class Phone + { + public string Number { get; set; } + public string Extenion { get; set; } + + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public PhoneType PhoneType { get; set; } + } + + public enum PhoneType + { + Home, + Mobile, + Work + } + + public static void SubscribeWithCustomType() + { + Phone myPhone = new Phone() + { + Number = "111-222-2222", + PhoneType = PhoneType.Mobile, + Extenion = "11" + }; + + pubnub.Publish() + .Message(myPhone) + .Channel("my_channel") + .ShouldStore(true) + .Execute(new PNPublishResultExt( + (result, status) => + { + // Check whether request successfully completed or not. + if (status.Error) + { + // something bad happened. + Debug.Log("error happened while publishing: " + + pubnub.JsonPluggableLibrary.SerializeToJsonString(status)); + } + else + { + Debug.Log("publish worked! timetoken: " + result.Timetoken.ToString()); + } + } + )); + + SubscribeCallbackListener objectListenerSubscribeCallack = new SubscribeCallbackListener(); + objectListenerSubscribeCallack.onMessage += (pubnubObj, message) => { + //message.Message gives the Phone object because you subscribed to type Phone during subscribe. + }; + + pubnub.AddListener(objectListenerSubscribeCallack); + pubnub.Subscribe() + .Channels(new string[] + { + "my_channel" // subscribe to channels + }) + .Execute(); + + //If you are subscribing to multiple message types, then + SubscribeCallbackListener stringListenerSubscribeCallback = new SubscribeCallbackListener(); + stringListenerSubscribeCallback.onMessage += (pubnubObj, message) => { + //message.Message gives the string object because you subscribed to type "string" during subscribe. + string phoneStringMessage = message.Message.ToString(); //this is your string message + //using pluggable JSON library from the Pubnub instance, but you can use any form of JSON deserialization you wish + var deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToObject(phoneStringMessage); + }; + + pubnub.AddListener(stringListenerSubscribeCallback); + pubnub.Subscribe() + .Channels(new string[] + { + "my_channel" // subscribe to channels + }) + .Execute(); + } + // snippet.end + + public static void CreateSubscriptionSetFromIndividual() + { + // snippet.create_subscription_set_from_individual + // Create a subscription from a channel entity + Subscription subscription1 = pubnub.Channel("channelName").Subscription(); + + // Create a subscription from a channel group entity + Subscription subscription2 = pubnub.ChannelGroup("channelGroupName").Subscription(); + + // create a subscription set from individual entities + SubscriptionSet subscriptionSet = subscription1.Add(subscription2); + + subscriptionSet.Subscribe(); + // snippet.end + } + + public static void WildcardSubscribe() + { + // snippet.wildcard_subscribe + pubnub.Subscribe() + .Channels(new string[] + { + // subscribe to channels information + "foo.*" + }) + .Execute(); + // snippet.end + } + + public static void UnsubscribeBasicUsage() + { + // snippet.unsubscribe_basic_usage + pubnub.Unsubscribe() + .Channels(new string[] + { + "my_channel" + }) + .Execute(); + // snippet.end + } + + public static void UnsubscribeMultipleChannels() + { + // snippet.unsubscribe_multiple_channels + pubnub.Unsubscribe() + .Channels(new string[] + { + "ch1", + "ch2", + "ch3" + }) + .ChannelGroups(new string[] + { + "cg1", + "cg2", + "cg3" + }) + .Execute(); + // snippet.end + } + + public static void UnsubscribeChannelGroup() + { + // snippet.unsubscribe_channel_group + pubnub.Unsubscribe() + .ChannelGroups(new string[] + { + "cg1", + "cg2", + "cg3" + }) + .Execute(); + // snippet.end + } + + public static void UnsubscribeAllBasicUsage() + { + // snippet.unsubscribe_all_basic_usage + pubnub.UnsubscribeAll(); + // snippet.end + } + + public static void AddListenerBasicUsage() + { + // snippet.add_listener_basic_usage + // Add event-specific listeners + // Add a listener to receive Message changes + Subscription subscription1 = pubnub.Channel("channelName").Subscription(); + + subscription1.onMessage += (Pubnub pn, PNMessageResult messageEvent) => + { + Debug.Log($"Message received {messageEvent.Message}"); + }; + + subscription1.Subscribe(); + + + // Add multiple listeners + SubscribeCallbackListener eventListener = new SubscribeCallbackListener( + delegate(Pubnub pn, PNMessageResult messageEvent) + { + Debug.Log($"received message {messageEvent.Message}"); + }, + delegate(Pubnub pn, PNPresenceEventResult e) { Debug.Log("Presence event"); }, + delegate(Pubnub pn, PNSignalResult e) { Debug.Log("Signal event"); }, + delegate(Pubnub pn, PNObjectEventResult e) { Debug.Log("Object event"); }, + delegate(Pubnub pn, PNMessageActionEventResult e) { Debug.Log("Message Action event"); }, + delegate(Pubnub pn, PNFileEventResult e) { Debug.Log("File event"); }, + delegate(Pubnub pn, PNStatus e) { Debug.Log("Status event"); } + ); + + Channel firstChannel = pubnub.Channel("first"); + var subscription = firstChannel.Subscription(SubscriptionOptions.ReceivePresenceEvents); + subscription.AddListener(eventListener); + subscription.Subscribe(); + // snippet.end + } + + public static void AddListenersBasicUsage() + { + // snippet.add_listeners_basic_usage + Subscription subscription1 = pubnub.Channel("channelName").Subscription(); + + SubscriptionSet subscriptionSet = pubnub.SubscriptionSet( + new string[] { "channel1", "channel2" }, + new string[] { "channel_group_1", "channel_group_2" }, + SubscriptionOptions.ReceivePresenceEvents + ); + + SubscribeCallbackListener eventListener = new SubscribeCallbackListener(); + eventListener.onMessage += delegate(Pubnub pn, PNMessageResult messageEvent) { + Debug.Log($"received message {messageEvent.Message}"); + }; + eventListener.onPresence += delegate(Pubnub pn, PNPresenceEventResult e) { Debug.Log("Presence event"); }; + eventListener.onStatus += delegate(Pubnub pn, PNStatus s) { Debug.Log("Status event"); }; + + subscription1.AddListener(eventListener); + subscriptionSet.onSignal += (Pubnub pn, PNSignalResult signalEvent) => + { + Debug.Log($"Message received {signalEvent.Message}"); + }; + + subscription1.Subscribe(); + subscriptionSet.Subscribe(); + // snippet.end + } + + public static void AddListenerMethod1() + { + // snippet.add_listener_method1 + // Adding listener. + pubnub.AddListener(new SubscribeCallbackListener( + delegate(Pubnub pnObj, PNMessageResult pubMsg) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(pubMsg)); + var channelName = pubMsg.Channel; + var channelGroupName = pubMsg.Subscription; + var pubTT = pubMsg.Timetoken; + var msg = pubMsg.Message; + var publisher = pubMsg.Publisher; + }, + delegate(Pubnub pnObj, PNPresenceEventResult presenceEvnt) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(presenceEvnt)); + var action = presenceEvnt.Event; // Can be join, leave, state-change or timeout + var channelName = presenceEvnt.Channel; // The channel for which the message belongs + var occupancy = presenceEvnt.Occupancy; // No. of users connected with the channel + var state = presenceEvnt.State; // User State + var channelGroupName = + presenceEvnt.Subscription; // The channel group or wildcard subscription match (if exists) + var publishTime = presenceEvnt.Timestamp; // Publish timetoken + var timetoken = presenceEvnt.Timetoken; // Current timetoken + var uuid = presenceEvnt.Uuid; // UUIDs of users who are connected with the channel + }, + delegate(Pubnub pnObj, PNSignalResult signalMsg) + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(signalMsg)); + var channelName = signalMsg.Channel; // The channel for which the signal belongs + var channelGroupName = + signalMsg.Subscription; // The channel group or wildcard subscription match (if exists) + var pubTT = signalMsg.Timetoken; // Publish timetoken + var msg = signalMsg.Message; // The Payload + var publisher = signalMsg.Publisher; //The Publisher + }, + delegate(Pubnub pnObj, PNObjectEventResult objectEventObj) + { + var channelName = objectEventObj.Channel; // Channel + var channelMetadata = objectEventObj.ChannelMetadata; //Channel Metadata + var uidMetadata = objectEventObj.UuidMetadata; // UUID metadata + var evnt = objectEventObj.Event; // Event + var type = objectEventObj.Type; // Event type + if (objectEventObj.Type == "uuid") + { + /* got uuid metadata related event. */ + } + else if (objectEventObj.Type == "channel") + { + /* got channel metadata related event. */ + } + else if (objectEventObj.Type == "membership") + { + /* got membership related event. */ + } + + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(objectEventObj)); + }, + delegate(Pubnub pnObj, PNMessageActionEventResult msgActionEvent) + { + //handle message action + var channelName = msgActionEvent.Channel; // The channel for which the message belongs + var msgEvent = msgActionEvent.Action; // message action added or removed + var msgActionType = msgActionEvent.Event; // message action type + var messageTimetoken = msgActionEvent.MessageTimetoken; // The timetoken of the original message + var actionTimetoken = msgActionEvent.ActionTimetoken; //The timetoken of the message action + }, + delegate(Pubnub pnObj, PNFileEventResult fileEvent) + { + //handle file message event + var channelName = fileEvent.Channel; + var chanelGroupName = fileEvent.Subscription; + var fieldId = (fileEvent.File != null) ? fileEvent.File.Id : null; + var fileName = (fileEvent.File != null) ? fileEvent.File.Name : null; + var fileUrl = (fileEvent.File != null) ? fileEvent.File.Url : null; + var fileMessage = fileEvent.Message; + var filePublisher = fileEvent.Publisher; + var filePubTT = fileEvent.Timetoken; + }, + delegate(Pubnub pnObj, PNStatus pnStatus) + { + Debug.Log($"{pnStatus.Operation} {pnStatus.Category} {pnStatus.StatusCode}"); + var affectedChannelGroups = + pnStatus.AffectedChannelGroups; // The channel groups affected in the operation, of type array. + var affectedChannels = + pnStatus.AffectedChannels; // The channels affected in the operation, of type array. + var category = pnStatus.Category; //Returns PNConnectedCategory + var operation = pnStatus.Operation; //Returns PNSubscribeOperation + } + )); + + //Add listener to receive Signal messages + SubscribeCallbackListener signalSubscribeCallback = new SubscribeCallbackListener(); + signalSubscribeCallback.onSignal += delegate (Pubnub pubnubObj, PNSignalResult message) { + // Handle new signal message stored in message.Message + }; + signalSubscribeCallback.onStatus += delegate (Pubnub pubnubObj, PNStatus status) { + // the status object returned is always related to subscribe but could contain + // information about subscribe, heartbeat, or errors + }; + pubnub.AddListener(signalSubscribeCallback); + + //Add listener to receive Events + SubscribeCallbackListener eventListener = new SubscribeCallbackListener(); + eventListener.onObject += delegate(Pubnub pnObj, PNObjectEventResult objectEvent) { + string channelMetadataId = objectEvent.Channel; // The channel + string uuidMetadataId = objectEvent.UuidMetadata.Uuid; // The UUID + string objEvent = objectEvent.Event; // The event name that occurred + string eventType = objectEvent.Type; // The event type that occurred + PNUuidMetadataResult uuidMetadata = objectEvent.UuidMetadata; // UuidMetadata + PNChannelMetadataResult channelMetadata = objectEvent.ChannelMetadata; // ChannelMetadata + }; + pubnub.AddListener(eventListener); + // snippet.end + } + + // snippet.add_listener_method2 + public class DevSubscribeCallback : SubscribeCallback + { + public override void Message(Pubnub pubnub, PNMessageResult message) + { + // Handle new message stored in message.Message + } + + public override void Presence(Pubnub pubnub, PNPresenceEventResult presence) + { + // handle incoming presence data + } + + public override void Signal(Pubnub pubnub, PNSignalResult signal) + { + // Handle new signal message stored in signal.Message + } + + public override void Status(Pubnub pubnub, PNStatus status) + { + // the status object returned is always related to subscribe but could contain + // information about subscribe, heartbeat, or errors + // use the PNOperationType to switch on different options + switch (status.Operation) + { + // let's combine unsubscribe and subscribe handling for ease of use + case PNOperationType.PNSubscribeOperation: + case PNOperationType.PNUnsubscribeOperation: + // note: subscribe statuses never have traditional + // errors, they just have categories to represent the + // different issues or successes that occur as part of subscribe + switch (status.Category) + { + case PNStatusCategory.PNConnectedCategory: + // this is expected for a subscribe, this means there is no error or issue whatsoever + break; + case PNStatusCategory.PNReconnectedCategory: + // this usually occurs if subscribe temporarily fails but reconnects. This means + // there was an error but there is no longer any issue + break; + case PNStatusCategory.PNDisconnectedCategory: + // this is the expected category for an unsubscribe. This means there + // was no error in unsubscribing from everything + break; + case PNStatusCategory.PNUnexpectedDisconnectCategory: + // this is usually an issue with the internet connection, this is an error, handle appropriately + break; + case PNStatusCategory.PNAccessDeniedCategory: + // this means that Access Manager does allow this client to subscribe to this + // channel and channel group configuration. This is another explicit error + break; + default: + // More errors can be directly specified by creating explicit cases for other + // error categories of `PNStatusCategory` such as `PNTimeoutCategory` or `PNMalformedFilterExpressionCategory` or `PNDecryptionErrorCategory` + break; + } + + break; + case PNOperationType.PNHeartbeatOperation: + // heartbeat operations can in fact have errors, so it is important to check first for an error. + if (status.Error) + { + // There was an error with the heartbeat operation, handle here + } + else + { + // heartbeat operation was successful + } + + break; + default: + // Encountered unknown status type + break; + } + } + + public override void ObjectEvent(Pubnub pubnub, PNObjectEventResult objectEvent) + { + // handle incoming user, space and membership event data + } + + public override void MessageAction(Pubnub pubnub, PNMessageActionEventResult messageAction) + { + // handle incoming message action events + } + + public override void File(Pubnub pubnub, PNFileEventResult fileEvent) + { + // handle incoming file messages + } + } + + public static void AddListenerMethod2() + { + // Usage of the above listener + DevSubscribeCallback regularListener = new DevSubscribeCallback(); + pubnub.AddListener(regularListener); + } + // snippet.end + + public static void RemoveListener() + { + // snippet.remove_listener + SubscribeCallbackListener listenerSubscribeCallback = new SubscribeCallbackListener(); + pubnub.AddListener(listenerSubscribeCallback); + + // some time later + pubnub.RemoveListener(listenerSubscribeCallback); + // snippet.end + } + + public static void AddConnectionStatusListener() + { + // snippet.add_connection_status_listener + SubscribeCallbackListener eventListener = new SubscribeCallbackListener(); + eventListener.onStatus += delegate(Pubnub pn, PNStatus e) { Debug.Log("Status event"); }; + + pubnub.AddListener(eventListener); + // snippet.end + } + + public static void UnsubscribeNewBasicUsage() + { + // snippet.unsubscribe_new_basic_usage + Subscription subscription1 = pubnub.Channel("channelName").Subscription(); + + SubscriptionSet subscriptionSet = pubnub.SubscriptionSet( + new string[] { "channel1", "channel2" }, + new string[] { "channel_group_1", "channel_group_2" }, + SubscriptionOptions.ReceivePresenceEvents + ); + + subscription1.Subscribe(); + subscriptionSet.Subscribe(); + + subscription1.Unsubscribe(); + subscriptionSet.Unsubscribe(); + // snippet.end + } + + public static void UnsubscribeAllNewBasicUsage() + { + // snippet.unsubscribe_all_new_basic_usage + Subscription subscription1 = pubnub.Channel("channelName").Subscription(); + + SubscriptionSet subscriptionSet = pubnub.SubscriptionSet( + new string[] { "channel1", "channel2" }, + new string[] { "channel_group_1", "channel_group_2" }, + SubscriptionOptions.ReceivePresenceEvents + ); + + subscription1.Subscribe(); + subscriptionSet.Subscribe(); + + pubnub.UnsubscribeAll(); + // snippet.end + } + + public static void Entities() { + // snippet.create_channel + var channel = pubnub.Channel("channelName"); + + // Listener to add relevant callbacks to + SubscribeCallbackListener channelListener = new SubscribeCallbackListener(); + + channel.Subscription().AddListener(channelListener); + channel.Subscription().Subscribe(); + // snippet.end + + // snippet.create_channel_group + var channelGroup = pubnub.ChannelGroup("channelGroupName"); + + // Listener to add relevant callbacks to + SubscribeCallbackListener channelGroupListener = new SubscribeCallbackListener(); + + channelGroup.Subscription().AddListener(channelGroupListener); + channelGroup.Subscription().Subscribe(); + // snippet.end + + // snippet.create_channel_metadata + var channelMetadata = pubnub.ChannelMetadata("channelMetadata"); + + // Listener to add relevant callbacks to + SubscribeCallbackListener channelMetadataListener = new SubscribeCallbackListener(); + + channelMetadata.Subscription().AddListener(channelMetadataListener); + channelMetadata.Subscription().Subscribe(); + // snippet.end + + // snippet.create_user_metadata + var userMetadata = pubnub.UserMetadata("userMetadata"); + + // Listener to add relevant callbacks to + SubscribeCallbackListener userMetadataListener = new SubscribeCallbackListener(); + + userMetadata.Subscription().AddListener(userMetadataListener); + userMetadata.Subscription().Subscribe(); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Publish/PublishSubscribeSample.cs.meta b/PubNubUnity/Assets/Snippets/Publish/PublishSubscribeSample.cs.meta new file mode 100644 index 00000000..a1852cbe --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Publish/PublishSubscribeSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6b35143dfc3a48543819cca0b9def635 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Publish/PubnubBasicUsageExample.cs b/PubNubUnity/Assets/Snippets/Publish/PubnubBasicUsageExample.cs new file mode 100644 index 00000000..831a9041 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Publish/PubnubBasicUsageExample.cs @@ -0,0 +1,64 @@ +// snippet.pubnub_basic_usage +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class PubnubBasicUsageExample : MonoBehaviour { + + //Reference to a pubnub manager previously setup in Unity Editor + //For more details see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + //An editor-serialized string with the test channel ID + [SerializeField] private string testChannelId = "test_channel_id"; + + private async void Start() { + //Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + //Subscribing to string messages on an example channel + pubnub.Subscribe().Channels(new []{testChannelId}).Execute(); + + //Setting up a simple callback on receiving a message + pubnubManager.listener.onMessage += (pn, result) => { + Debug.Log($"Received a message on {result.Channel}: {result.Message}"); + }; + + //Sending a message that will be received by our callback + var publishResult = await pubnub.Publish().Message("Hello from PubNub!").Channel(testChannelId).ExecuteAsync(); + + //Doing simple error handling in case something went wrong during the publish + if (publishResult.Status.Error) { + Debug.LogError($"Error in publish operation: {publishResult.Status.ErrorData.Information}"); + } + } + + // You can also use Pubnub inside Unity without any editor-side setup: + private async void NoEditorSetupExample() { + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + //Setting up a simple callback on receiving a message + SubscribeCallbackListener listener = new SubscribeCallbackListener(); + listener.onMessage += (pn, result) => { + Debug.Log($"Received a message on {result.Channel}: {result.Message}"); + }; + pubnub.AddListener(listener); + + //Subscribing to string messages on an example channel + pubnub.Subscribe().Channels(new []{testChannelId}).Execute(); + + //Sending a message that will be received by our callback + var publishResult = await pubnub.Publish().Message("Hello from PubNub!").Channel(testChannelId).ExecuteAsync(); + + //Doing simple error handling in case something went wrong during the publish + if (publishResult.Status.Error) { + Debug.LogError($"Error in publish operation: {publishResult.Status.ErrorData.Information}"); + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Publish/PubnubBasicUsageExample.cs.meta b/PubNubUnity/Assets/Snippets/Publish/PubnubBasicUsageExample.cs.meta new file mode 100644 index 00000000..ac38d676 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Publish/PubnubBasicUsageExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3b9308767dac40979f0e274c02869a54 +timeCreated: 1751287203 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Push.meta b/PubNubUnity/Assets/Snippets/Push.meta new file mode 100644 index 00000000..99d23e81 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Push.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0f11711cf8daa474082ed8ffa49ffc6e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Push/AddPushNotificationsExample.cs b/PubNubUnity/Assets/Snippets/Push/AddPushNotificationsExample.cs new file mode 100644 index 00000000..6a69eccb --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Push/AddPushNotificationsExample.cs @@ -0,0 +1,64 @@ +// snippet.add_device_to_channel_basic_usage +using PubnubApi; +using PubnubApi.Unity; +using UnityEngine; + +public class AddPushNotificationsExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + // An editor-serialized array for the channels to add notifications + [SerializeField] private string[] channels = { "ch1", "ch2", "ch3" }; + + // An editor-serialized string for the device IDs + [SerializeField] private string fcmDeviceId = "googleDevice"; + [SerializeField] private string apnsDeviceId = "appleDevice"; + + // An editor-serialized string for the APNS2 topic + [SerializeField] private string apnsTopic = "myapptopic"; + + private void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Adding FCM/GCM push notifications + pubnub.AddPushNotificationsOnChannels() + .PushType(PNPushType.FCM) + .Channels(channels) + .DeviceId(fcmDeviceId) + .Execute((result, status) => { + if (status.Error) { + Debug.LogError($"Error adding FCM notifications: {status.ErrorData.Information}"); + } else { + Debug.Log("Successfully added FCM notifications."); + } + }); + + // Adding APNS2 push notifications + pubnub.AddPushNotificationsOnChannels() + .PushType(PNPushType.APNS2) + .Channels(channels) + .DeviceId(apnsDeviceId) + .Topic(apnsTopic) + .Environment(PushEnvironment.Development) + .Execute((result, status) => { + if (status.Error) { + Debug.LogError($"Error adding APNS2 notifications: {status.ErrorData.Information}"); + } else { + Debug.Log("Successfully added APNS2 notifications."); + } + }); + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Push/AddPushNotificationsExample.cs.meta b/PubNubUnity/Assets/Snippets/Push/AddPushNotificationsExample.cs.meta new file mode 100644 index 00000000..c19b4801 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Push/AddPushNotificationsExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0287251cb767449a97e32fa43704ac76 +timeCreated: 1751288096 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Push/PushSample.cs b/PubNubUnity/Assets/Snippets/Push/PushSample.cs new file mode 100644 index 00000000..10bb6bcd --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Push/PushSample.cs @@ -0,0 +1,119 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using UnityEngine; +using System; + +public class PushSample +{ + private static Pubnub pubnub; + + static void Init() + { + // snippet.pubnub_init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static void ListChannelsForDeviceBasicUsage() + { + // snippet.list_channels_for_device_basic_usage + // for FCM/GCM + pubnub.AuditPushChannelProvisions() + .DeviceId("googleDevice") + .PushType(PNPushType.FCM) + .Execute(new PNPushListProvisionsResultExt((r, s) => + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); + })); + + // for APNS2 + pubnub.AuditPushChannelProvisions() + .DeviceId("appleDevice") + .PushType(PNPushType.APNS2) + .Topic("myapptopic") + .Environment(PushEnvironment.Development) + .Execute(new PNPushListProvisionsResultExt((r, s) => + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); + })); + // snippet.end + } + + public static void RemoveDeviceFromChannelBasicUsage() + { + // snippet.remove_device_from_channel_basic_usage + // for FCM/GCM + pubnub.RemovePushNotificationsFromChannels() + .DeviceId("googleDevice") + .Channels(new string[] { + "ch1", + "ch2", + "ch3" + }) + .PushType(PNPushType.FCM) + .Execute(new PNPushRemoveChannelResultExt((r, s) => + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); + })); + + // for APNS2 + pubnub.RemovePushNotificationsFromChannels() + .DeviceId("appleDevice") + .Channels(new string[] { + "ch1", + "ch2", + "ch3" + }) + .PushType(PNPushType.APNS2) + .Topic("myapptopic") + .Environment(PushEnvironment.Development) + .Execute(new PNPushRemoveChannelResultExt((r, s) => + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); + })); + // snippet.end + } + + public static void RemoveAllPushNotificationsBasicUsage() + { + // snippet.remove_all_push_notifications_basic_usage + // for FCM/GCM + pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken() + .DeviceId("googleDevice") + .PushType(PNPushType.FCM) + .Execute(new PNPushRemoveAllChannelsResultExt((r, s) => { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); + })); + + // for APNS2 + pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken() + .DeviceId("appleDevice") + .PushType(PNPushType.APNS2) + .Topic("myapptopic") + .Environment(PushEnvironment.Development) + .Execute(new PNPushRemoveAllChannelsResultExt((r, s) => { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r)); + })); + // snippet.end + } +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Push/PushSample.cs.meta b/PubNubUnity/Assets/Snippets/Push/PushSample.cs.meta new file mode 100644 index 00000000..ed910f00 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Push/PushSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c3a0bb5b5f3ae7f4cb48424e9e051f6a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Storage.meta b/PubNubUnity/Assets/Snippets/Storage.meta new file mode 100644 index 00000000..edcb16b3 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Storage.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c34321e2eea32c9429b0f533164ad460 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PubNubUnity/Assets/Snippets/Storage/FetchLastMessageExample.cs b/PubNubUnity/Assets/Snippets/Storage/FetchLastMessageExample.cs new file mode 100644 index 00000000..f603ef4b --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Storage/FetchLastMessageExample.cs @@ -0,0 +1,52 @@ +// snippet.fetch_history_basic_usage +using PubnubApi.Unity; +using UnityEngine; + +public class FetchLastMessageExample : MonoBehaviour { + // Reference to a pubnub manager previously setup in Unity Editor + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + [SerializeField] private PNManagerBehaviour pubnubManager; + + // An editor-serialized string for the channel ID + [SerializeField] private string channelId = "my_channel"; + + private async void Start() { + // Getting a reference to the Pubnub instance + var pubnub = pubnubManager.pubnub; + + // Note that you can also initialize Pubnub instance for Unity directly from code: + /* + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + }; + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + */ + + // Fetching the last message from the specified channel + var fetchHistoryResponse = await pubnub.FetchHistory() + .Channels(new string[] { channelId }) + .IncludeMeta(true) + .MaximumPerChannel(1) // Changed to 1 to specifically get the last message + .IncludeCustomMessageType(true) + .ExecuteAsync(); + + // Checking the result and status of the fetch operation + var fetchResult = fetchHistoryResponse.Result; + var status = fetchHistoryResponse.Status; + + if (status.Error) { + Debug.LogError($"Error fetching history: {status.ErrorData.Information}"); + } else if (fetchResult != null && fetchResult.Messages.ContainsKey(channelId)) { + var messages = fetchResult.Messages[channelId]; + if (messages.Count > 0) { + var lastMessage = messages[0]; + Debug.Log($"Last message: {lastMessage.Entry}, Timetoken: {lastMessage.Timetoken}"); + } else { + Debug.Log("No messages found."); + } + } + } +} +// snippet.end \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Storage/FetchLastMessageExample.cs.meta b/PubNubUnity/Assets/Snippets/Storage/FetchLastMessageExample.cs.meta new file mode 100644 index 00000000..56bad2b9 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Storage/FetchLastMessageExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 94ee21f242634b37b519bd955009ff38 +timeCreated: 1751286943 \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Storage/StorageAndPlaybackSample.cs b/PubNubUnity/Assets/Snippets/Storage/StorageAndPlaybackSample.cs new file mode 100644 index 00000000..6913e868 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Storage/StorageAndPlaybackSample.cs @@ -0,0 +1,320 @@ +// snippet.using +using PubnubApi; +using PubnubApi.Unity; + +// snippet.end +using System.Threading.Tasks; +using UnityEngine; +using System; +using System.Threading; + +public class StorageAndPlaybackSample +{ + private static Pubnub pubnub; + + static void Init() + { + // snippet.pubnub_init + // Configuration + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")) + { + SubscribeKey = "demo", + PublishKey = "demo", + Secure = true + }; + + // Initialize PubNub + Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + + // If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour + // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub + /* + [SerializeField] private PNManagerBehaviour pubnubManager; + Pubnub pubnub = pubnubManager.pubnub; + */ + + // snippet.end + } + + public static void FetchHistorySynchronous() + { + // snippet.fetch_history_synchronous + pubnub.FetchHistory() + .Channels(new string[] { "my_channel" }) + .IncludeMeta(true) + .MaximumPerChannel(25) + .Execute(new PNFetchHistoryResultExt((result, status) => + { + + })); + // snippet.end + } + + public static async Task DeleteMessagesBasicUsage() + { + // snippet.delete_messages_basic_usage + PNResult delMsgResponse = await pubnub.DeleteMessages() + .Channel("history_channel") + .Start(15088506076921021) + .End(15088532035597390) + .ExecuteAsync(); + + PNDeleteMessageResult delMsgResult = delMsgResponse.Result; + PNStatus status = delMsgResponse.Status; + + if (status != null && status.Error) + { + //Check for any error + Debug.Log(status.ErrorData.Information); + } + else if (delMsgResult != null) + { + //Expect empty object + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(delMsgResult)); + } + // snippet.end + } + + public static void DeleteMessagesSynchronous() + { + // snippet.delete_messages_synchronous + pubnub.DeleteMessages() + .Channel("history_channel") + .Start(15088506076921021) + .End(15088532035597390) + .Execute(new PNDeleteMessageResultExt( + (result, status) => { + if (status != null && status.Error) { + //Check for any error + Debug.Log(status.ErrorData.Information); + } + else if (result != null) { + //Expect empty object + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(result)); + } + } + )); + // snippet.end + } + + public static async Task DeleteSpecificMessage() + { + // snippet.delete_specific_message + PNResult delMsgResponse = await pubnub.DeleteMessages() + .Channel("history_channel") + .Start(15526611838554309) + .End(15526611838554310) + .ExecuteAsync(); + + PNDeleteMessageResult delMsgResult = delMsgResponse.Result; + PNStatus status = delMsgResponse.Status; + + if (status != null && status.Error) + { + //Check for any error + Debug.Log(status.ErrorData.Information); + } + else if (delMsgResult != null) + { + //Expect empty object + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(delMsgResult)); + } + // snippet.end + } + + public static async Task MessageCountsBasicUsage() + { + // snippet.message_counts_basic_usage + PNResult msgCountResponse = await pubnub.MessageCounts() + .Channels(new string[] { "message_count_channel" }) + .ChannelsTimetoken(new long[] { 15088506076921021 }) + .ExecuteAsync(); + + PNMessageCountResult msgCountResult = msgCountResponse.Result; + PNStatus status = msgCountResponse.Status; + + if (status != null && status.Error) + { + //Check for any error + Debug.Log(status.ErrorData.Information); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(msgCountResult)); + } + // snippet.end + } + + public static void MessageCountsSynchronous() + { + // snippet.message_counts_synchronous + pubnub.MessageCounts() + .Channels(new string[] { "message_count_channel" }) + .ChannelsTimetoken(new long[] { 15088506076921021 }) + .Execute(new PNMessageCountResultExt( + (result, status) => { + if (status != null && status.Error) + { + //Check for any error + Debug.Log(status.ErrorData.Information); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(result)); + } + })); + // snippet.end + } + + public static async Task MessageCountsMultipleChannels() + { + // snippet.message_counts_multiple_channels + PNResult msgCountResponse = await pubnub.MessageCounts() + .Channels(new string[] { "message_count_channel", "message_count_channel2" }) + .ChannelsTimetoken(new long[] { 15088506076921021, 15088506076921131 }) + .ExecuteAsync(); + + PNMessageCountResult msgCountResult = msgCountResponse.Result; + PNStatus status = msgCountResponse.Status; + + if (status != null && status.Error) + { + //Check for any error + Debug.Log(status.ErrorData.Information); + } + else + { + Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(msgCountResult)); + } + // snippet.end + } + + public static async Task HistoryBasicUsage() + { + // snippet.history_basic_usage + PNResult historyResponse = await pubnub.History() + .Channel("history_channel") // where to fetch history from + .Count(100) // how many items to fetch + .ExecuteAsync(); + // snippet.end + } + + public static void HistorySynchronous() + { + // snippet.history_synchronous + pubnub.History() + .Channel("history_channel") // where to fetch history from + .Count(100) // how many items to fetch + .Execute(new PNHistoryResultExt( + (result, status) => { + } + )); + // snippet.end + } + + public static async Task HistoryReverse() + { + // snippet.history_reverse + PNResult historyResponse = await pubnub.History() + .Channel("my_channel") // where to fetch history from + .Count(3) // how many items to fetch + .Reverse(true) // should go in reverse? + .ExecuteAsync(); + // snippet.end + } + + public static async Task HistoryStartTimetoken() + { + // snippet.history_start_timetoken + PNResult historyResponse = await pubnub.History() + .Channel("my_channel") // where to fetch history from + .Start(13847168620721752L) // first timestamp + .Reverse(true) // should go in reverse? + .ExecuteAsync(); + // snippet.end + } + + public static async Task HistoryStartEndTimetoken() + { + // snippet.history_start_end_timetoken + PNResult historyResponse = await pubnub.History() + .Channel("my_channel") // where to fetch history from + .Count(100) // how many items to fetch + .Start(-1) // first timestamp + .End(13847168819178600L) // last timestamp + .Reverse(true) // should go in reverse? + .ExecuteAsync(); + // snippet.end + } + + public static async Task HistoryIncludeTimetoken() + { + // snippet.history_include_timetoken + PNResult historyResponse = await pubnub.History() + .Channel("history_channel") // where to fetch history from + .Count(100) // how many items to fetch + .IncludeTimetoken(true) // include timetoken with each entry + .ExecuteAsync(); + // snippet.end + } + + // snippet.history_paging_example + public class PubnubRecursiveHistoryFetcher { + private static Pubnub pubnub; + + public abstract class CallbackSkeleton { + public abstract void HandleResponse(PNHistoryResult result); + } + + public PubnubRecursiveHistoryFetcher() { + // NOTICE: for demo/demo pub/sub keys Message Persistence is disabled, + // so use your pub/sub keys instead + PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId")); + pnConfiguration.SubscribeKey = "demo"; + pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration); + } + + static public void Main() { + PubnubRecursiveHistoryFetcher fetcher = new PubnubRecursiveHistoryFetcher(); + GetAllMessages(new DemoCallbackSkeleton()); + } + + public static void GetAllMessages(CallbackSkeleton callback) { + GetAllMessages(-1L, callback); + } + + public static void GetAllMessages(long startTimestamp, CallbackSkeleton callback) { + CountdownEvent latch = new CountdownEvent(1); + + pubnub.History() + .Channel("history_channel") // where to fetch history from + .Count(100) // how many items to fetch + .Start(startTimestamp) // first timestamp + .Execute(new DemoHistoryResult(callback)); + } + + public class DemoHistoryResult : PNCallback { + CallbackSkeleton internalCallback; + public DemoHistoryResult(CallbackSkeleton callback) { + this.internalCallback = callback; + } + public override void OnResponse(PNHistoryResult result, PNStatus status) { + if (!status.Error && result != null && result.Messages != null && result.Messages.Count > 0) { + Debug.Log(result.Messages.Count); + Debug.Log("start:" + result.StartTimeToken.ToString()); + Debug.Log("end:" + result.EndTimeToken.ToString()); + + internalCallback.HandleResponse(result); + GetAllMessages(result.EndTimeToken, this.internalCallback); + } + } + }; + + public class DemoCallbackSkeleton : CallbackSkeleton { + public override void HandleResponse(PNHistoryResult result) { + //Handle the result + } + } + } + // snippet.end +} \ No newline at end of file diff --git a/PubNubUnity/Assets/Snippets/Storage/StorageAndPlaybackSample.cs.meta b/PubNubUnity/Assets/Snippets/Storage/StorageAndPlaybackSample.cs.meta new file mode 100644 index 00000000..5bd75c97 --- /dev/null +++ b/PubNubUnity/Assets/Snippets/Storage/StorageAndPlaybackSample.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 326889fd92331ce4395c7562bcfb2a6d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VERSION b/VERSION index 37ad5c8b..47da986f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -9.0.1 +9.1.0