digits.c 459 B

1234567891011121314151617181920212223242526
  1. /* digits.c */
  2. #include <math.h>
  3. #include "ransurf.h"
  4. int Digits(double Double, int MaxSig)
  5. {
  6. int I, Round;
  7. double Check, RD, Right;
  8. G_debug(2, "SigDigits");
  9. I = 0;
  10. Double += 1.0;
  11. while (I < MaxSig) {
  12. Check = Double * pow(10.0, 1.0 * I);
  13. Round = (int)Check;
  14. RD = Round;
  15. Right = fabs(RD - Check);
  16. if (Right == 0.0)
  17. return (I);
  18. I++;
  19. }
  20. return (MaxSig);
  21. }