4 ms·
What about comparison operators?
by nivertech 5mo ago
What 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.