From 22892ca6c2f68df005622b2e4daf246a649a4d1b Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 18 Aug 2014 08:06:37 +0000 Subject: sprintf.c: remove magic numbers * sprintf.c (rb_str_format): name default float precision and remove unused initial value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sprintf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sprintf.c') diff --git a/sprintf.c b/sprintf.c index c4f304fafc..69920c6443 100644 --- a/sprintf.c +++ b/sprintf.c @@ -455,6 +455,7 @@ rb_f_sprintf(int argc, const VALUE *argv) VALUE rb_str_format(int argc, const VALUE *argv, VALUE fmt) { + enum {default_float_precision = 6}; rb_encoding *enc; const char *p, *end; char *buf; @@ -1030,7 +1031,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) { VALUE val = GETARG(); double fval; - int i, need = 6; + int i, need; char fbuf[32]; fval = RFLOAT_VALUE(rb_Float(val)); @@ -1082,7 +1083,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) if (i > 0) need = BIT_DIGITS(i); } - need += (flags&FPREC) ? prec : 6; + need += (flags&FPREC) ? prec : default_float_precision; if ((flags&FWIDTH) && need < width) need = width; need += 20; -- cgit v1.2.3