summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-10-28 10:45:43 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-10-28 10:45:43 -0700
commitc6c4da8c484e0e3ba748806b6616ca165fafe562 (patch)
treed107739348c6be69a84c68efe8efe28f888385c7 /include
parentd7d5c15b54e764497aa69667d3e5d849469eb373 (diff)
parent15f46a1feba74cba4f25ec99df79a3f1e07b0b09 (diff)
downloadmruby-c6c4da8c484e0e3ba748806b6616ca165fafe562.tar.gz
mruby-c6c4da8c484e0e3ba748806b6616ca165fafe562.zip
Merge pull request #510 from masuidrive/master
define convert method mrb_int/mrb_float with C string
Diffstat (limited to 'include')
-rw-r--r--include/mrbconf.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index 76c1b37f9..841ef1823 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -55,19 +55,26 @@
#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) (mrb_float)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) (mrb_float)strtod((buf),NULL)
#endif
-#define readfloat(p) (mrb_float)strtod((p),NULL)
#ifdef MRB_NAN_BOXING
typedef int32_t mrb_int;
#define MRB_INT_MIN INT32_MIN
#define MRB_INT_MAX INT32_MAX
+#define mrb_int_to_str(buf, i) sprintf((buf), "%d", (i))
+#define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10);
#else
typedef int mrb_int;
#define MRB_INT_MIN INT_MIN
#define MRB_INT_MAX INT_MAX
+#define mrb_int_to_str(buf, i) sprintf((buf), "%d", (i))
+#define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10);
#endif
typedef short mrb_sym;