MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / fromNumber

Method fromNumber

projects/JavaScript/proto/int64.js:1053–1067  ·  view source on GitHub ↗

* Returns UInt64 representing the given value, provided that it is a finite number. Otherwise, zero is returned. * @param {number} value 32-bit integer value * @returns {!UInt64} The corresponding UInt64 value

(value)

Source from the content-addressed store, hash-verified

1051 * @returns {!UInt64} The corresponding UInt64 value
1052 */
1053 static fromNumber (value) {
1054 if (isNaN(value)) {
1055 return UINT64_ZERO
1056 }
1057 if (value < 0) {
1058 return UINT64_ZERO
1059 }
1060 if (value >= UINT64_TWO_PWR_64_DBL) {
1061 return UINT64_MAX
1062 }
1063 if (value < 0) {
1064 return UInt64.fromNumber(-value).neg()
1065 }
1066 return UInt64.fromBits((value % UINT64_TWO_PWR_32_DBL) | 0, (value / UINT64_TWO_PWR_32_DBL) | 0)
1067 }
1068
1069 /**
1070 * Returns UInt64 representation of the given string, written using the specified radix.

Callers

nothing calls this directly

Calls 3

negMethod · 0.45
fromNumberMethod · 0.45
fromBitsMethod · 0.45

Tested by

no test coverage detected