string_helpers: fix precision loss for some inputs