Guest User

Untitled

a guest
Jun 18th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. %g
  2.  
  3. %g
  4.  
  5. %g
  6.  
  7. %g
  8.  
  9. %g
  10.  
  11. #include <math.h>
  12. double x;
  13. ...
  14. if (floor(x) == x && x != 0.0) { // x is an non-zero integer value
  15. int digits = floor(log10(fabs(x)+0.5)) + 1;
  16. printf("x is %.*fn", digits, x);
  17. }
  18.  
  19. x log10(x+0.5)
  20. 1 0.176091259055681000
  21. 9 0.977723605288848000
  22. 10 1.021189299069940000
  23. 99 1.997823080745730000
  24. 100 2.002166061756510000
  25. 999 2.999782798454140000
  26. 1000 3.000217092972230000
  27. 10000 4.000021714181250000
  28. 100000 5.000002171466980000
  29. 1000000 6.000000217147190000
  30. 10000000 7.000000021714720000
  31. 100000000 8.000000002171470000
  32. 1000000000 9.000000000217150000
Add Comment
Please, Sign In to add comment