diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-26 11:17:47 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-26 17:29:18 +0900 |
| commit | c019d8d34d2db5de218802d923e6d0197a2ffca0 (patch) | |
| tree | f0b18c2c7ab657f7f6bf4a324048d59cb41ecee7 /src/fmt_fp.c | |
| parent | 05cc3a8d9958c618aafc4b01548a85834f23dd6d (diff) | |
| download | mruby-c019d8d34d2db5de218802d923e6d0197a2ffca0.tar.gz mruby-c019d8d34d2db5de218802d923e6d0197a2ffca0.zip | |
fmt_fp.c: move mruby specific `mrb_float_to_str` to `numeric.c`
Diffstat (limited to 'src/fmt_fp.c')
| -rw-r--r-- | src/fmt_fp.c | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/src/fmt_fp.c b/src/fmt_fp.c index 8a156b3d9..6f4828d99 100644 --- a/src/fmt_fp.c +++ b/src/fmt_fp.c @@ -361,28 +361,4 @@ mrb_format_float(mrb_float f, char *buf, size_t buf_size, char fmt, int prec, ch return s - buf; } - -MRB_API mrb_value -mrb_float_to_str(mrb_state *mrb, mrb_value flo) -{ - char buf[25]; -#ifdef MRB_USE_FLOAT32 - const int prec = 7; -#else - const int prec = 15; -#endif - - mrb_format_float(mrb_float(flo), buf, sizeof(buf), 'g', prec, '\0'); - for (char *p = buf; *p; p++) { - if (*p == '.') goto exit; - if (*p == 'e') { - memmove(p+2, p, strlen(p)+1); - memcpy(p, ".0", 2); - goto exit; - } - } - strcat(buf, ".0"); - exit: - return mrb_str_new_cstr(mrb, buf); -} #endif |
