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

Method fromNumber

projects/JavaScript/proto/int64.js:139–153  ·  view source on GitHub ↗

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

(value)

Source from the content-addressed store, hash-verified

137 * @returns {!Int64} The corresponding Int64 value
138 */
139 static fromNumber (value) {
140 if (isNaN(value)) {
141 return INT64_ZERO
142 }
143 if (value <= -INT64_TWO_PWR_63_DBL) {
144 return INT64_MIN
145 }
146 if (value + 1 >= INT64_TWO_PWR_63_DBL) {
147 return INT64_MAX
148 }
149 if (value < 0) {
150 return Int64.fromNumber(-value).neg()
151 }
152 return Int64.fromBits((value % INT64_TWO_PWR_32_DBL) | 0, (value / INT64_TWO_PWR_32_DBL) | 0)
153 }
154
155 /**
156 * Returns Int64 representation of the given string, written using the specified radix.

Callers 15

setMethod · 0.45
setMethod · 0.45
setMethod · 0.45
setMethod · 0.45
setMethod · 0.45
setMethod · 0.45
copyMethod · 0.45
copyMethod · 0.45
fromStringMethod · 0.45
fromValueMethod · 0.45
toStringMethod · 0.45
mulMethod · 0.45

Calls 2

negMethod · 0.45
fromBitsMethod · 0.45

Tested by

no test coverage detected