fork(2) download
  1. #include <stdio.h>
  2.  
  3. unsigned long bits0(unsigned long num) {
  4. int count = 0; while(num) num >>=1, ++count; return count;
  5. }
  6.  
  7. unsigned long bits1(unsigned long num) {
  8. int float_order_le = 1;
  9. union { unsigned int u[2]; double d; } t;
  10. t.u[float_order_le] = 0x43300000;
  11. t.u[!float_order_le] = num;
  12. t.d -= 4503599627370496.0;
  13. return ((t.u[float_order_le] >> 20) - 0x3FF) + 1;
  14. }
  15.  
  16. int main(int argc, char **argv) {
  17. unsigned long d = 0x01000001;
  18. printf("%lu\n%lu", bits0(d), bits1(d));
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
25
25