Skip to content

Instantly share code, notes, and snippets.

View cruxicheiros's full-sized avatar

Clark Seanor cruxicheiros

View GitHub Profile
@cruxicheiros
cruxicheiros / refactored-ternary.js
Last active March 27, 2020 02:10
The refactored ternary - IEEE 754
function isSpecialCase(exponent, bias) {
return exponent == (bias << 1) + 1
}
function handleSpecialCases(significand, signal) {
if (significand) {
return NaN;
} else if (signal) {
return -Infinity;
} else {
@cruxicheiros
cruxicheiros / worksheet.js
Created March 27, 2020 02:05
Unpicking a lump of ternary into something meaningful
// The original:
function doMath(bias, significand, signal, exponent) {
return exponent == (bias << 1) + 1
? significand
? NaN
: signal
? -Infinity
: +Infinity
: (1 + signal * -2) *