fork download
  1. #include <stdio.h>
  2.  
  3. double fisr(double number);
  4.  
  5. int main(void) {
  6. double a = 2;
  7. //scanf("%lf", &a);
  8. printf("%lfn", fisr(a));
  9.  
  10. return 0;
  11. }
  12.  
  13. double fisr(double number) {
  14. long i;
  15. float x2, y;
  16. const float threehalfs = 1.5F;
  17.  
  18. x2 = number * 0.5F;
  19. y = number;
  20. i = * ( long * ) &y; // evil floating point bit level hacking
  21. i = 0x5f3759df - ( i >> 1 ); // what the fuck?
  22. y = * ( float * ) &i;
  23. y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
  24. // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
  25.  
  26. return y;
  27. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
0.706930n