in reply to Re^2: sprintf values
in thread sprintf values

I think sv_vcatpvfn can or does use the C runtime to format floats. Even if it doesn't, the C runtime is used to create the floats in the first place, so it definitely matters.

Replies are listed 'Best First'.
Re^4: sprintf values
by almut (Canon) on Apr 07, 2010 at 17:09 UTC

    I just re-checked with ltrace, and yes you're right, it does in fact call snprintf() and frexp() to format floats.

    I had done a similar check some time ago, and was surprised to not find any libc calls related to Perl's s/printf()  (which is why I posted) — but that must have been without a float format specifier being used... (rather only integer formatting like %d, %u etc.)   As to the creation of floats, however, I don't see any calls to libc or libm. Any idea what function that would be (just out of curiosity)?

      toke.c 13286 if (floatit) { 13287 /* terminate the string */ 13288 *d = '\0'; 13289 nv = Atof(PL_tokenbuf); 13290 sv_setnv(sv, nv); 13291 }

      I didn't track Atof all the way through since I found comments in perl.h indicate Perl usually uses Perl's own atof implementation, but it can be configured to the native implementation (and does so on UNICOS).