(x: Interval | IntervalResult)
| 377 | * Base-2 logarithm. |
| 378 | */ |
| 379 | export function log2(x: Interval | IntervalResult): IntervalResult { |
| 380 | const unwrapped = unwrapOrPropagate(x); |
| 381 | if (!Array.isArray(unwrapped)) return unwrapped; |
| 382 | const [xVal] = unwrapped; |
| 383 | if (xVal.hi <= 0) { |
| 384 | return { kind: 'empty' }; |
| 385 | } |
| 386 | |
| 387 | if (xVal.lo > 0) { |
| 388 | return ok({ lo: Math.log2(xVal.lo), hi: Math.log2(xVal.hi) }); |
| 389 | } |
| 390 | |
| 391 | return { |
| 392 | kind: 'partial', |
| 393 | value: { lo: -Infinity, hi: Math.log2(xVal.hi) }, |
| 394 | domainClipped: 'lo', |
| 395 | }; |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * Absolute value of an interval. |
nothing calls this directly
no test coverage detected