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):
I'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 ==.
It'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.
I'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.
The slogan of the Russian Revolution of 1917 was: "Factories to the workers, land to the peasants."
If the factory is yours, then everything inside is yours ;)
But it's funny how low wages under the broken Soviet economic system turned such things into a semi-official, informal work perks, allowing people to make ends meet.
It was less the low wages and more the general unavailability of things (shortages). Lots of things you couldn't just buy but you had to know somebody who knew somebody.
I wouldn't call it "funny" though. It ws quite sad and I'm glad it's over.
As I mentioned in another commebt, I don't even consider anything related to that to be a viable government system.
That said, the general unavailability of everything was caused by an incompetent government rather the the system itself but the system itself caused the government.
My point is that it was a succession of demagogueries hiding personal interests that caused the recurring and unrecoverable tragedies of that state. Being controlled and misguided is not exclusive to any particular government or political system.
This is not false but totally an oversimplification.
I don't think communism is a good form of government and I don't think the soviet union was marching the right way.
But the biggest blunts came from other much more serious mistakes caused by politicians ignoring science, like the big famine and many others, including the Chernobyl connerie
1. The problem is with using HTTP for APIs, not with GraphQL. HTTP was designed for rich (hypertext) documents, not for APIs. So layering GraphQL or any other APIs over HTTP is a hack.
2. GraphQL is useful for small remote teams b/c of mandatory staticly-typed schema and built-in schema documentation. Otherwise it's lots of back-and-forth between backen, frontend, QA, etc. You forced to use external tools like Postman collections, and still having communication problems.
reply