summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-02-16 14:42:01 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-02-16 14:42:01 +0900
commita88a20d51f5877b231877261d29fee9d66a20214 (patch)
treee3b993e905b6afa11c6c1ccd0feb3741e4db13fb /include
parent1fa081a6468f830fc9fe20c7215a9655eceabc61 (diff)
parent6f893b5183450384e89b3d8f03f9ef32a7522624 (diff)
downloadmruby-a88a20d51f5877b231877261d29fee9d66a20214.tar.gz
mruby-a88a20d51f5877b231877261d29fee9d66a20214.zip
Merge pull request #2723 from cremno/use-musl-fmt_fp
re-implement mrb_float_to_str()
Diffstat (limited to 'include')
-rw-r--r--include/mruby/numeric.h2
-rw-r--r--include/mruby/value.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/include/mruby/numeric.h b/include/mruby/numeric.h
index 3020dbd93..94cdbccee 100644
--- a/include/mruby/numeric.h
+++ b/include/mruby/numeric.h
@@ -17,6 +17,8 @@ extern "C" {
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, int base);
+/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
+MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
mrb_value mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y);
diff --git a/include/mruby/value.h b/include/mruby/value.h
index 9297f6b28..f27800366 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -34,11 +34,9 @@ struct mrb_state;
#ifdef MRB_USE_FLOAT
typedef float mrb_float;
-# define mrb_float_to_str(buf, i) sprintf(buf, "%.7e", i)
# define str_to_mrb_float(buf) strtof(buf, NULL)
#else
typedef double mrb_float;
-# define mrb_float_to_str(buf, i) sprintf(buf, "%.16e", i)
# define str_to_mrb_float(buf) strtod(buf, NULL)
#endif