in reply to sprintf zero-fill issue

Unfortunately, using printf numeric formats doesn't interact well with perl's habit of storing things in whatever form it thinks best, be it floating point, integer, or unsigned integer.

Any of the numeric formats will result in a C-level cast into the type specified by the format (though perl will use the correct length modifiers, never casting to int or float when it's using long or double). So %e, %f, and %g cast to a floating point number, potentially losing precision if perl is using 64 bit integer types, while %d, %u, %o, %x can lose precision or range or cast an unsigned to signed or vice versa.

A simple example:

$ perl $x = 2**65; printf("%d\n", $x); __END__ -1
Here, $x is a floating point value. Perl knows you want an integer type, so it tries to convert it, but it's out of range, so UV_MAX is used instead (likely 2**32-1 or 2**64-1) but that is cast to a signed integer type, giving -1.

You're best off sticking to an %s (or %_) format whenever possible.