diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-21 07:37:13 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-22 09:35:27 +0900 |
| commit | 328563995f7c817fc4ec1e92ffcadfde101ced06 (patch) | |
| tree | 8c3b942eb5fc919bfa48c25018d969dd7eeeb801 /include | |
| parent | fa29bb3bb4801c8ca0256bcd2559ceb159110f68 (diff) | |
| download | mruby-328563995f7c817fc4ec1e92ffcadfde101ced06.tar.gz mruby-328563995f7c817fc4ec1e92ffcadfde101ced06.zip | |
fmt_fp.c: replace with public domain float format routine; ref #5448
The original code can be found in `https://github.com/dhylands/format-float`.
Changes:
- support `double`
- support `#` (alt_form) modifier
- small refactoring
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby/numeric.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/mruby/numeric.h b/include/mruby/numeric.h index 2eed1b051..8f8635189 100644 --- a/include/mruby/numeric.h +++ b/include/mruby/numeric.h @@ -165,13 +165,14 @@ MRB_API mrb_float mrb_as_float(mrb_state *mrb, mrb_value x); /* internal functions */ mrb_float mrb_div_float(mrb_float x, mrb_float y); -/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */ mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x); -int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f); +int mrb_format_float(mrb_float f, char *buf, size_t buf_size, char fmt, int prec, char sign); /* obsolete functions; will be removed */ #define mrb_flo_to_fixnum(mrb, val) mrb_float_to_integer(mrb, val) #define mrb_to_flo(mrb, x) mrb_as_float(mrb, x) +/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */ +int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f); #endif /* MRB_NO_FLOAT */ |
