| 49 | * it can guard a frequent operation. |
| 50 | */ |
| 51 | export function isOutsideNormalDoubleRange(x: number): boolean { |
| 52 | return !( |
| 53 | Math.abs(x) >= 2.2250738585072014e-308 && Math.abs(x) <= Number.MAX_VALUE |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | // When applying simplifications, only considers integers whose absolute value |
| 58 | // is less than SMALL_INTEGER. This avoid loss of precision by preventing |
| 59 | // simplification for `1e199 + 1`. |
| 60 | // Note: SMALL_INTEGER ≈ 10^(MACHINE_PRECISION / 2) |
| 61 | // so that the product of two small integers does not lose precision |
| 62 | export const SMALL_INTEGER = 1000000; |
| 63 | |
| 64 | /** The largest number of digits of a bigint */ |
| 65 | export const MAX_BIGINT_DIGITS = 1024; |
| 66 | |
| 67 | // When doing a calculation via iteration (e.g. to calculate a sum) |
| 68 | // do not iterate more than this value |
| 69 | // Reduced from 1,000,000 to 10,000 for better test performance |
| 70 | // while still being sufficient for most practical calculations |
| 71 | export const MAX_ITERATION = 10000; |