Figure out overflow/underflow for log/exp calculations Projection: Rotated: 0..0x7ffc Log: 0..0x3ffc Exp: (log(0x280) == 0x27c6) + (-0x3ffc..0x3ffc) = -0x1836..0x67c2 Result: 0..0x3ffe or 0x8000 Projection overflow: Exp: (log(0x3ffe) == 0x3bb8) + (-0x3ffc..0x0000) = -0.0446..0x3bb8 Result: 0..0x3ffe Span: Span: 0..0x7ffc Log: 0..0x3ffc Exp: (log(0x200) == 0x2668) + (-0x3ffc..0x0000) = -0x1994..0x2668 Will want to make 2^spanBits greater than eyeScreenDistance to ensure log range union doesn't span more than 0x7ffe However, they are measuring the same thing. Figure out what to do once we've written the top-level triangle rendering code Result: 0..0x0200 Intersect: Span ratio log: -0x3ffc..0x0000 Coord: -0x3ffe..0x3ffe Coord log: 0x0000..0x3bb8 Exp: (0x0000..0x3bb8) + (-0x3ffc..0x0000) = -0x3ffc..0x3bb8 Result: 0..0x3fea Our log calculation can underflow by 0x27c6 (we'd be fine if we were multiplying by 0x280 instead of midpoint) We have 0x4446 of overflow value 0x8000s (16 octaves) so we can just mask off high bit Except that would break sign bit, so need to shl and sar 60 octaves, 30 per sign (16 overflow, 13.416 normal, 0.586 zero) Can we just do shl without sar? (adjusting scale factor of span calculation as well to match) This would cause maximum intersect to be 0x7fd4 which would overflow when we added span or 1<