You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.8KB

  1. /**
  2. * Copyright (c) 2011-2019 Bill Greiman
  3. * This file is part of the SdFat library for SD memory cards.
  4. *
  5. * MIT License
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef FmtNumber_h
  26. #define FmtNumber_h
  27. #include <math.h>
  28. #include <stdint.h>
  29. #include <stddef.h>
  30. inline bool isDigit(char c) {
  31. return '0' <= (c) && (c) <= '9';
  32. }
  33. inline bool isSpace(char c) {
  34. return (c) == ' ' || (0X9 <= (c) && (c) <= 0XD);
  35. }
  36. char* fmtBase10(char* str, uint16_t n);
  37. char* fmtBase10(char* str, uint32_t n);
  38. char* fmtDouble(char *str, double d, uint8_t prec, bool altFmt);
  39. char* fmtDouble(char* str, double d, uint8_t prec, bool altFmt, char expChar);
  40. char* fmtHex(char* str, uint32_t n);
  41. char* fmtSigned(char* str, int32_t n, uint8_t base, bool caps);
  42. char* fmtUnsigned(char* str, uint32_t n, uint8_t base, bool caps);
  43. #endif // FmtNumber_h