You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Derek Gottfrid <dg...@gmail.com> on 2007/05/25 18:14:22 UTC

issue w/ formatting %g

I see behavior from apr_psprintf using the %g format flag that I do
from normal printf on linux and solaris.  It doesn't prepend a leading
zero for values  between 1 and -1 -ie  .3 instead of 0.3

Is there any interested other than mine in changing this behavior?

derek


Sample

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <apr_strings.h>

int main(int argc, char **argv) {
        apr_pool_t *mpool;
        double g = .3;
        apr_status_t status = apr_initialize();
        status = apr_pool_create(&mpool,NULL);
        printf("%g\n",g);
        printf("%s\n",apr_psprintf(mpool,"%g",g));
        apr_pool_destroy(mpool);
        apr_terminate();
        return 0;
}

output:

0.3
.3