mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
1767764791
commit
22892ca6c2
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue