diff options
| author | Rasmus Lerdorf <rasmus@php.net> | 2000-07-14 18:46:13 +0000 |
|---|---|---|
| committer | Rasmus Lerdorf <rasmus@php.net> | 2000-07-14 18:46:13 +0000 |
| commit | e3fd1edc4917dc52d0d400ad74e70dcbead689a5 (patch) | |
| tree | 777966970e226742bb449c4426866af8bf763982 /ext/standard/math.c | |
| parent | 0bba8eeae18d7a9818b45be131375f756195ae5c (diff) | |
| download | php-git-e3fd1edc4917dc52d0d400ad74e70dcbead689a5.tar.gz | |
Make it possible to specify an empty string as a thousands-seperator
in number_format()
@ Make it possible to specify an empty string as a thousands-seperator
@ in number_format()
Diffstat (limited to 'ext/standard/math.c')
| -rw-r--r-- | ext/standard/math.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/standard/math.c b/ext/standard/math.c index 588bedc329..c0d770ca87 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -637,9 +637,9 @@ char *_php_math_number_format(double d,int dec,char dec_point,char thousand_sep) } if (dec) { - reslen = dec+1 + (tmplen-dec-1) + (tmplen-1-dec-1)/3; + reslen = dec+1 + (tmplen-dec-1) + ((thousand_sep) ? (tmplen-1-dec-1)/3 : 0); } else { - reslen = tmplen+(tmplen-1)/3; + reslen = tmplen+((thousand_sep) ? (tmplen-1)/3 : 0); } if (is_negative) { reslen++; @@ -660,7 +660,7 @@ char *_php_math_number_format(double d,int dec,char dec_point,char thousand_sep) while(s>=tmpbuf) { *t-- = *s--; - if ((++count%3)==0 && s>=tmpbuf) { + if (thousand_sep && (++count%3)==0 && s>=tmpbuf) { *t-- = thousand_sep; } } @@ -709,6 +709,8 @@ PHP_FUNCTION(number_format) } if ((*t_s)->value.str.len==1) { thousand_sep=(*t_s)->value.str.val[0]; + } else if((*t_s)->value.str.len==0) { + thousand_sep=0; } RETURN_STRING(_php_math_number_format((*num)->value.dval,(*dec)->value.lval,dec_point,thousand_sep),0); break; |
