25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
523 B

  1. #include <string.h>
  2. #include "double-conversion.h"
  3. using namespace double_conversion;
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. // Returns the length of the string
  8. int
  9. double_to_shortest(char *buf, size_t size, double val)
  10. {
  11. int len = -1;
  12. StringBuilder builder(buf, size);
  13. const DoubleToStringConverter& dc =
  14. DoubleToStringConverter::EcmaScriptConverter();
  15. dc.ToShortest(val, &builder);
  16. len = builder.position();
  17. buf = builder.Finalize();
  18. return len;
  19. }
  20. #ifdef __cplusplus
  21. }
  22. #endif