(value)
| 703 | } |
| 704 | |
| 705 | function float16ToFloat32(value) { |
| 706 | const sign = (value & 0x8000) >> 15; |
| 707 | const exponent = (value & 0x7c00) >> 10; |
| 708 | const fraction = value & 0x03ff; |
| 709 | |
| 710 | let result; |
| 711 | if (exponent === 0) { |
| 712 | if (fraction === 0) { |
| 713 | result = 0; |
| 714 | } else { |
| 715 | result = (fraction / 0x400) * Math.pow(2, -14); |
| 716 | } |
| 717 | } else if (exponent === 0x1f) { |
| 718 | result = fraction === 0 ? Number.POSITIVE_INFINITY : Number.NaN; |
| 719 | } else { |
| 720 | result = (1 + fraction / 0x400) * Math.pow(2, exponent - 15); |
| 721 | } |
| 722 | |
| 723 | return sign === 1 ? -result : result; |
| 724 | } |
| 725 | |
| 726 | function decodeFloat16Base64(base64, expectedLength) { |
| 727 | const bytes = decodeBase64ToUint8Array(base64); |
no outgoing calls
no test coverage detected