summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYuichiro MASUI <[email protected]>2012-10-27 14:26:50 +0900
committerYuichiro MASUI <[email protected]>2012-10-27 14:26:50 +0900
commit15f46a1feba74cba4f25ec99df79a3f1e07b0b09 (patch)
tree04bbc7fceaf3ee7ddbcfb1dfbf623aaebff720ef /include
parent559933f577d5073464aa06facc1b754de6225d8a (diff)
downloadmruby-15f46a1feba74cba4f25ec99df79a3f1e07b0b09.tar.gz
mruby-15f46a1feba74cba4f25ec99df79a3f1e07b0b09.zip
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;