define convert method mrb_int/mrb_float with C string

This commit is contained in:
Yuichiro MASUI
2012-10-27 14:26:50 +09:00
parent 559933f577
commit 15f46a1feb
5 changed files with 21 additions and 14 deletions
+8 -1
View File
@@ -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;