sr_si_string_u64() and thus also sr_samplerate_string() and other functions that use it don't handle all possible input correctly. For example, sr_samplerate_string(1234) correctly yields "1.234 kHz", but sr_samplerate_string(1004) yields "1.4 kHz" instead of "1.004 kHz".
Created attachment 36 [details] Patch to format decimals correctly in sr_si_string_u64() The patch is very simple and achieves a string which at least formats a correct value. Maybe more work to strip trailing decimal 0:s could be added on top, should that be desirable.
Peter's patch still fails tests, as some of test cases expected no trailing zeroes. So, I went to implement trimming them, and turned out that tests are actually inconsistent and some expect trailing zeroes, and some don't. So, I had to patch testcases too after all. New patch added, it supersedes Peter's.
Created attachment 37 [details] This patch fixes missing leading zeroes, trims trailing, and makes sure tests are consistent re: trailing zeroes.
Created attachment 38 [details] Fix sr_si_string_u64() test cases.
Created attachment 39 [details] Format decimals correctly in sr_si_string_u64()
Yesterday there was no opinion on trailing zeros so I went for the simplest possible patch. Today there was consensus to drop trailing zeros, but I didn't like Paul's implementation of formatting so I implemented the formatting in a different way. Paul's commit to fix the test cases should be applied first!
The latest attached files don't have any patch hunks in them.
Created attachment 40 [details] Fix sr_si_string_u64() test cases. from Paul's patch
Created attachment 41 [details] Format decimals correctly in sr_si_string_u64()
Sorry about that! I've fixed the attachments now.
Thanks guys, fixed in ba253f2bb97b7a69ad8b486f411d8d81d33792a4 and 094e6b815972240fbc210f8c5ef2eaa8c989fbc0. Sorry for the delay.