4 ms·
FP2 spec: 00 -> 0.0 01 -> 1.0 10 -> Inf 11 -> NaN or 00 -> 0.0 01 -> 1.0 10 -> Inf 11 -> -Inf
by nivertech 5mo ago
FP2 spec:
00 -> 0.0
01 -> 1.0
10 -> Inf
11 -> NaN
or
00 -> 0.0
01 -> 1.0
10 -> Inf
11 -> -Inf
- tim333 5mo agoI guess my first car's four speed box was a bit like a FP2 float. Lever forward/back, right/left -> 3.65, 2.15, 1.42, 1.00 ratios.
- 0-_-0 5mo ago00 -> 0.0 01 ->-0.0 10 -> Inf 11 -> -Inf
- amavect 5mo ago00 -> 0.0 01 -> +1.0 10 -> NaN 11 -> -1.0 Arithmetic: 0.0 + x = x NaN + x = NaN +1.0 + -1.0 = 0.0 +1.0 + +1.0 = NaN -1.0 + -1.0 = NaN -0.0 = 0.0 -(+1.0) = -1.0 -(-1.0) = +1.0 -NaN = NaN x - y = x + (-y) NaN * x = NaN +1.0 * x = x -1.0 * x = -x 0.0 * 0.0 = 0.0 /0.0 = NaN /+1.0 = +1.0 /-1.0 = -1.0 /NaN = NaN x / y = x * (/y) More interestingly, how to implement in logic gates. Addition with a 2's complement full adder and NaN detector. Negation with a 2's complement negation circuit. Reciprocal with a 0.0 detector. Multiplication with a unique logic circuit (use a Karnaugh map): (ab * cd) = (a&~b | c&~d | ~a&b&c | a&~c&d)(b & d)
- nivertech 5mo agoWhat about comparison operators?
- amavect 5mo agoI'll use custom notation =? ≤≥? <? ≤? for comparison to distinguish from = < ≤. x =? x = True Otherwise, a =? b = False NaN ≤≥? NaN = False Otherwise, a ≤≥? b = a =? b -1.0 <? 0.0 = True -1.0 <? +1.0 = True 0.0 <? +1.0 = True Otherwise, a <? b = False a >? b = b <? a a ≤? b = (a <? b | a ≤≥? b) a ≥? b = (a >? b | a ≤≥? b) In logic gates: For =?, bitwise equality. For ≤≥?, bitwise equality and a NaN detector. For <?, use: ab <? cd = a&b&~c | ~a&~b&~c&d I separate =? from ≤≥?. =? compares value, while ≤≥? compares order. NaN has no ordering, so it compares false. IEEE float only uses ≤≥? and names it ==.
- nivertech 5mo agoIt's better to first show truth tables, then K-maps, and only then logical formulas. But the main question is: does this FP2 have any real applications? Maybe it could be useful when only one operand is FP2? Especially for vectorized math.
- amavect 5mo agoI'm just having fun. I wrote out the full truth tables and Karnaugh maps on paper, but I trust that you get the idea and can recreate it yourself. (Or, I can write a more detailed blog post, if you'd find that interesting.) If I had to guess, we could use this for a very compact output of the sign function. [-Inf,0) maps to -1.0, 0 maps to 0.0, (0,Inf] maps to +1.0, and NaN maps to NaN. I don't know what application would need the sign function, though. I haven't needed it yet in my programming experience.