Number to be encoded later
Desired encoding. Default: 'f', which uses the preferred float encoding, even for integers.
Boxed number or bigint object with hidden property set containing the desired encoding.
Return a boxed number encoded in the desired (often non-optimal) format.
This might be used for APIs that have strict encoding requirements where
the normal JS number does not always create the correct encoding.
NOTES: -0 is always encoded as -0, without simplification, as long as the
selected encoding is floating point. Otherwise, -0 causes an error.
You MUST NOT use the ignoreOriginalEncoding
option when encoding these
numbers, or the encoding that is stored along with the boxed number will
be ignored. The cde
and dcbor
options turn on ignoreOriginalEncoding
by default, so it must be exlicitly disabled.
Number to be encoded later
Desired encoding. Default: 'f', which uses the preferred float encoding, even for integers.
Optional
majorType: numberBoxed number or bigint object with hidden property set containing the desired encoding.
Return a boxed number encoded in the desired (often non-optimal) format.
This might be used for APIs that have strict encoding requirements where
the normal JS number does not always create the correct encoding.
NOTES: -0 is always encoded as -0, without simplification, as long as the
selected encoding is floating point. Otherwise, -0 causes an error.
You MUST NOT use the ignoreOriginalEncoding
option when encoding these
numbers, or the encoding that is stored along with the boxed number will
be ignored. The cde
and dcbor
options turn on ignoreOriginalEncoding
by default, so it must be exlicitly disabled.
Number to be encoded later
Desired encoding. Default: 'f', which uses the preferred float encoding, even for integers.
Optional
majorType: numberBoxed number or bigint object with hidden property set containing the desired encoding.
Return a boxed number encoded in the desired (often non-optimal) format.
This might be used for APIs that have strict encoding requirements where
the normal JS number does not always create the correct encoding.
NOTES: -0 is always encoded as -0, without simplification, as long as the
selected encoding is floating point. Otherwise, -0 causes an error.
You MUST NOT use the ignoreOriginalEncoding
option when encoding these
numbers, or the encoding that is stored along with the boxed number will
be ignored. The cde
and dcbor
options turn on ignoreOriginalEncoding
by default, so it must be exlicitly disabled.
Number to be encoded later
Optional
encoding: "f" | "f16" | "f32" | "f64"Desired encoding. Default: 'f', which uses the preferred float encoding, even for integers.
Boxed number or bigint object with hidden property set containing the desired encoding.
Return a boxed number encoded in the desired (often non-optimal) format. This might be used for APIs that have strict encoding requirements where the normal JS number does not always create the correct encoding. NOTES: -0 is always encoded as -0, without simplification, as long as the selected encoding is floating point. Otherwise, -0 causes an error. You MUST NOT use the
ignoreOriginalEncoding
option when encoding these numbers, or the encoding that is stored along with the boxed number will be ignored. Thecde
anddcbor
options turn onignoreOriginalEncoding
by default, so it must be exlicitly disabled.