[#BloombergLP-bdljsn-JsonNumber]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdljsn.adoc[bdljsn]::JsonNumber
:relfileprefix: ../../
:mrdocs:

This class defines a value&hyphen;semantic class that represents a JSON number&period; Objects of this class have a value determined at construction and does not change except by assignment from or swap with another `JsonNumber` object&period; The value can be specified by supplying a string that conforms to the &lcub;JSON Textual Specification&rcub; or from one of the &lcub;Supported Types&rcub;&period; The value of a JSON object can be converted to any of those types&semi; however, some of those conversions can be inexact&period;

== Synopsis

Declared in `&lt;bdljsn&lowbar;jsonnumber&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class JsonNumber;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdljsn/JsonNumber/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias for `allocator&lowbar;type`&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdljsn/JsonNumber/_04enum.adoc[`Unnamed enum`] 
| Undocumented symbol&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdljsn/JsonNumber/2constructor-031.adoc[`JsonNumber`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdljsn/JsonNumber/operator_assign-0ad.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bdljsn/JsonNumber/allocator.adoc[`allocator`]  [.small]#[deprecated]#
| *DEPRECATED*&colon; Use `get&lowbar;allocator()` instead&period;
| xref:BloombergLP/bdljsn/JsonNumber/asDecimal64.adoc[`asDecimal64`] 
| Same as the related overload above for `asDecimal64`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asDecimal64Exact.adoc[`asDecimal64Exact`] 
| Load to the specified `result` the closest floating point representation to this number, even if a non&hyphen;zero status is returned&period; Return 0 if this number can be represented exactly, and return `k&lowbar;INEXACT` and load `result` with the closest approximation if `value` cannot be represented exactly&period; If this number is outside the representable range, load `result` with `&plus;INF` or `&hyphen;INF` (as appropriate)&period; A number can be represented exactly as a `Decimal64` if, for the significand and exponent, `abs(significand) &lt;&equals; 9,999,999,999,999,999` and `&hyphen;398 &lt;&equals; exponent &lt;&equals; 369`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asDouble.adoc[`asDouble`] 
| Same as the related overload above for `asDouble`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asFloat.adoc[`asFloat`] 
| Return the closest floating point representation to this number&period; If this number is outside the representable range, return `&plus;INF` or `&hyphen;INF` (as appropriate)&period; Note that values smaller than the smallest representable non&hyphen;zero value (a&period;k&period;a, `MIN`) are rounded to `MIN` (positive or negative, as appropriate) or 0, whichever is the better approximation&period;
| xref:BloombergLP/bdljsn/JsonNumber/asInt.adoc[`asInt`] 
| Same as the related overload above for `asInt`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asInt64.adoc[`asInt64`] 
| Same as the related overload above for `asInt64`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asLong.adoc[`asLong`] 
| Same as the related overload above for `asLong`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asLonglong.adoc[`asLonglong`] 
| Same as the related overload above for `asLonglong`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asShort.adoc[`asShort`] 
| Load into the specified `result` the integer value of this number&period; Return 0 on success, `k&lowbar;OVERFLOW` if `value` is larger than can be represented by `result`, `k&lowbar;UNDERFLOW` if `value` is smaller than can be represented by `result`, and `k&lowbar;NOT&lowbar;INTEGRAL` if `value` is not an integral number (i&period;e&period;, there is a fractional part)&period; For underflow, `result` will be loaded with the minimum representable value, for overflow, `result` will be loaded with the maximum representable value, for non&hyphen;integral values `result` will be loaded with the integer part of `value` (truncating the fractional part)&period; If the result is not an integer and also either overflows or underflows, it is treated as an overflow or underflow (respectively)&period; Note that this operation returns an error status value (unlike similar floating point conversions) because typically it is an error if a conversion to an integer results in an in&hyphen;exact value&period;
| xref:BloombergLP/bdljsn/JsonNumber/asUint.adoc[`asUint`] 
| Same as the related overload above for `asUint`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asUint64.adoc[`asUint64`] 
| Same as the related overload above for `asUint64`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asUlong.adoc[`asUlong`] 
| Same as the related overload above for `asUlong`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asUlonglong.adoc[`asUlonglong`] 
| Same as the related overload above for `asUlonglong`&period;
| xref:BloombergLP/bdljsn/JsonNumber/asUshort.adoc[`asUshort`] 
| Same as the related overload above for `asUshort`&period;
| xref:BloombergLP/bdljsn/JsonNumber/get_allocator.adoc[`get&lowbar;allocator`] 
| Return the allocator used by this object to supply memory&period;
| xref:BloombergLP/bdljsn/JsonNumber/isEqual.adoc[`isEqual`] 
| Return `true` if this number and the specified `other` number represent the same numeric value, and `false` otherwise&period; This method will return `true` for differing representations of the same number (e&period;g&period;, `1&period;0`, &quot;1&quot;, &quot;0&period;1e&plus;1&quot; are all equivalent) _except_ in cases where the exponent cannot be represented by a 64&hyphen;bit integer&period; If the exponent is outside the range of a 64&hyphen;bit integer, `true` will be returned if `&ast;this &equals;&equals; other`&period; For example, comparing &quot;1e18446744073709551615&quot; with itself will return `true`, but comparing it to &quot;10e18446744073709551614&quot; will return `false`&period; Note that this method is more computationally expensive than the equality and inequality operators&period;
| xref:BloombergLP/bdljsn/JsonNumber/isIntegral.adoc[`isIntegral`] 
| Return `true` if the value of this `JsonNumber` is an (exact) integral value, or `false` otherwise&period; Note that this function may return `true` even this number cannot be represented in a fundamental integral type&period;
| xref:BloombergLP/bdljsn/JsonNumber/print.adoc[`print`] 
| Write the value of this object to the specified output `stream` in a human&hyphen;readable format, and return a non&hyphen;`const` reference to `stream`&period; Optionally specify an initial indentation `level`, whose absolute value is incremented recursively for nested objects&period; If `level` is specified, optionally specify `spacesPerLevel`, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period; Note that the format is not fully specified, and can change without notice&period;
| xref:BloombergLP/bdljsn/JsonNumber/swap.adoc[`swap`] 
| Efficiently exchange the value of this object with the value of the specified `other` object&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee&period; The behavior is undefined unless this object was created with the same allocator as `other`&period;
| xref:BloombergLP/bdljsn/JsonNumber/value.adoc[`value`] 
| Return the textual representation of this `JsonNumber`&period;
| xref:BloombergLP/bdljsn/JsonNumber/2conversion-03b.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;JsonNumber, IsBitwiseMoveable&gt;`] 
| Declare nested type traits for this type&period;
| xref:BloombergLP/bdljsn/JsonNumber/2conversion-0e.adoc[`operator bdldfp::Decimal64`] 
| Same as the related overload above for `operator Decimal&lowbar;Type64`&period;
| xref:BloombergLP/bdljsn/JsonNumber/2conversion-0f.adoc[`operator double`] 
| Same as the related overload above for `operator double`&period;
| xref:BloombergLP/bdljsn/JsonNumber/2conversion-03d.adoc[`operator float`] 
| Return the closest floating point representation to this number&period; If this number is outside the representable range, return `&plus;INF` or `&hyphen;INF` (as appropriate)&period; Note that the values returned by these operators match those returned by `asFloat`, `asDouble`, and `asDecimal64`, respectively&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdljsn/JsonNumber/isValidNumber.adoc[`isValidNumber`] 
| Return `true` if the specified `text` complies with the grammar of a JSON number, and `false` otherwise&period; See the &lcub;JSON Textual Specification&rcub;&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdljsn/swap-088.adoc[BloombergLP::bdljsn::swap]`
| Exchange the values of the specified `a` and `b` objects&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if the two objects were created with the same allocator and the basic guarantee otherwise&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdljsn/operator_not_eq-010.adoc[`operator!&equals;`]
| Same as the related overload above for `operator!&equals;`&period;
| xref:BloombergLP/bdljsn/operator_not_eq-059.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise&period; Two `JsonNumber` objects do not have the same value if their `value` attributes are not the same&period;
| xref:BloombergLP/bdljsn/operator_eq-0a8.adoc[`operator&equals;&equals;`]
| Same as the related overload above for `operator&equals;&equals;`&period;
| xref:BloombergLP/bdljsn/operator_eq-0fe.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `JsonNumber` objects have the same value if their `value` attributes are the same&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
