fork download
  1. #include <stdio.h>
  2. #include <inttypes.h>
  3.  
  4. union wide_t {
  5. __int128 i;
  6. uint64_t a[2];
  7. };
  8.  
  9. int main(void) {
  10. union wide_t val;
  11.  
  12. val.i = -1;
  13. puts ((val.i & ((__int128) 1 << 127)) ? "negative" : "positive");
  14. printf("%016" PRIx64 "%016" PRIx64 "\n", val.a[1], val.a[0]);
  15.  
  16. // // -2^63 (it fits!)
  17. val.i = -9223372036854775808ull;
  18. puts ((val.i & ((__int128) 1 << 127)) ? "negative" : "positive");
  19.  
  20. val.i = -9223372036854775808ll;
  21. puts ((val.i & ((__int128) 1 << 127)) ? "negative" : "positive");
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
negative
ffffffffffffffffffffffffffffffff
positive
negative