prfdbl.c 896 B

123456789101112131415161718192021222324252627282930
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. /*
  5. * This is a simple test of the PR_fprintf() function for doubles.
  6. */
  7. #include "prprf.h"
  8. int main()
  9. {
  10. double pi = 3.1415926;
  11. double e = 2.71828;
  12. double root2 = 1.414;
  13. double zero = 0.0;
  14. double nan = zero / zero;
  15. PR_fprintf(PR_STDOUT, "pi is %f.\n", pi);
  16. PR_fprintf(PR_STDOUT, "e is %f.\n", e);
  17. PR_fprintf(PR_STDOUT, "The square root of 2 is %f.\n", root2);
  18. PR_fprintf(PR_STDOUT, "NaN is %f.\n", nan);
  19. PR_fprintf(PR_STDOUT, "pi is %301f.\n", pi);
  20. PR_fprintf(PR_STDOUT, "e is %65416.123f.\n", e);
  21. PR_fprintf(PR_STDOUT, "e is %0000000000000000000065416.123f.\n", e);
  22. PR_fprintf(PR_STDOUT, "NaN is %1024.1f.\n", nan);
  23. return 0;
  24. }