Skip to content

Commit e5348bb

Browse files
Small cleanup
1 parent c96c001 commit e5348bb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

f16.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ export function getFloat16(
1414
littleEndian = false,
1515
): number {
1616
let m = dataView.getUint16(offset, littleEndian);
17-
const s = m >> 8;
17+
let s = m >> 8;
1818
let e = s & 127;
19+
s >>= 7;
1920
m = (e & 3) * 256 + (m & 255);
2021
if ((e >>= 2) === 31) {
21-
m = m ? NaN : Infinity;
22-
} else {
23-
if (e) {
24-
m += 1024;
25-
e--;
26-
}
27-
m *= 2 ** (e - 24);
22+
return m ? NaN : (s ? -Infinity : Infinity);
23+
}
24+
if (e) {
25+
m += 1024;
26+
e--;
2827
}
29-
return (s >> 7) ? -m : m;
28+
m *= 2 ** (e - 24);
29+
return s ? -m : m;
3030
}
3131

3232
/**

0 commit comments

Comments
 (0)