[libc++][nfc] Move functions to a generic place.

This allows the floating-point formatter to use the same functions as
the integral formatter. This was tested in D114001.

GitOrigin-RevId: ed86610c7bcd5346d05db6a62fce6fb16eb83659
2 files changed