(bitLength, { unsigned })
| 2390 | return x5 === 0 ? 0 : x5; |
| 2391 | } |
| 2392 | function createIntegerConversion(bitLength, { unsigned }) { |
| 2393 | let lowerBound, upperBound; |
| 2394 | if (unsigned) { |
| 2395 | lowerBound = 0; |
| 2396 | upperBound = 2 ** bitLength - 1; |
| 2397 | } else { |
| 2398 | lowerBound = -(2 ** (bitLength - 1)); |
| 2399 | upperBound = 2 ** (bitLength - 1) - 1; |
| 2400 | } |
| 2401 | const twoToTheBitLength = 2 ** bitLength; |
| 2402 | const twoToOneLessThanTheBitLength = 2 ** (bitLength - 1); |
| 2403 | return (value, options = {}) => { |
| 2404 | let x5 = toNumber(value, options); |
| 2405 | x5 = censorNegativeZero(x5); |
| 2406 | if (options.enforceRange) { |
| 2407 | if (!Number.isFinite(x5)) { |
| 2408 | throw makeException(TypeError, "is not a finite number", options); |
| 2409 | } |
| 2410 | x5 = integerPart(x5); |
| 2411 | if (x5 < lowerBound || x5 > upperBound) { |
| 2412 | throw makeException( |
| 2413 | TypeError, |
| 2414 | `is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`, |
| 2415 | options |
| 2416 | ); |
| 2417 | } |
| 2418 | return x5; |
| 2419 | } |
| 2420 | if (!Number.isNaN(x5) && options.clamp) { |
| 2421 | x5 = Math.min(Math.max(x5, lowerBound), upperBound); |
| 2422 | x5 = evenRound(x5); |
| 2423 | return x5; |
| 2424 | } |
| 2425 | if (!Number.isFinite(x5) || x5 === 0) { |
| 2426 | return 0; |
| 2427 | } |
| 2428 | x5 = integerPart(x5); |
| 2429 | if (x5 >= lowerBound && x5 <= upperBound) { |
| 2430 | return x5; |
| 2431 | } |
| 2432 | x5 = modulo(x5, twoToTheBitLength); |
| 2433 | if (!unsigned && x5 >= twoToOneLessThanTheBitLength) { |
| 2434 | return x5 - twoToTheBitLength; |
| 2435 | } |
| 2436 | return x5; |
| 2437 | }; |
| 2438 | } |
| 2439 | function createLongLongConversion(bitLength, { unsigned }) { |
| 2440 | const upperBound = Number.MAX_SAFE_INTEGER; |
| 2441 | const lowerBound = unsigned ? 0 : Number.MIN_SAFE_INTEGER; |
no test coverage detected
searching dependent graphs…