Hi Kiste, I recently added print_float() to your print library 🙂. The format was based on what Kyle already described in the funcs.jal library.
Some thoughts from my side. I wonder why you should pass the formatting of the sdword like you suggested. Why not indicating that a thousand separator is required or not and if the type of separation is '.' (Europe style) or ',' (American style). You could pass this format as one parameter, e.g.: 0 = no thousand separator 1 = thousand separator using '.' 2 = thousand separator using ',' So 12345678 could be written as: 12345678 (no thoudsand separation) or 12.345.678 (thousand separation using '.') or 12,345,678 (thousand separation using ',') Kind regards, Rob ________________________________ Van: 'Oliver Seitz' via jallib <[email protected]> Verzonden: dinsdag 22 december 2020 12:59 Aan: Jallib <[email protected]> Onderwerp: [jallib] format library Hi all :-) It's been nine days and nine years since the original print library was finally replaced by my version. I remember, I've said then, that I would also do the format library soon. I feel like it's about time now... So, usually when I start thinking about improvement, I'm focused on mimicking the current behavior as close as possible. Yet... This is what it currently does: format_sdword(output,12345678, 6,0) -> 5678 format_sdword(output,12345678, 7,0) -> �45678 format_sdword(output,12345678, 7,1) -> �4567.8 format_sdword(output,12345678, 8,0) -> C345678 format_sdword(output,12345678, 8,1) -> C34567.8 format_sdword(output,12345678, 8,2) -> C3456.78 format_sdword(output,12345678, 9,0) -> 12345678 format_sdword(output,12345678, 9,1) -> 1234567.8 format_sdword(output,12345678, 9,2) -> 123456.78 format_sdword(output,12345678,10,0) -> 12345678 format_sdword(output,12345678,10,1) -> 1234567.8 format_sdword(output,12345678,10,2) -> 123456.78 format_sdword(output,12345678,11,0) -> 12345678 format_sdword(output,12345678,11,1) -> 1234567.8 format_sdword(output,12345678,11,2) -> 123456.78 format_sdword(output,12345678,12,0) -> 12345678 format_sdword(output,12345678,12,1) -> 1234567.8 format_sdword(output,12345678,12,2) -> 123456.78 format_sdword(output,12345678,13,0) -> 12345678 format_sdword(output,12345678,13,1) -> 1234567.8 format_sdword(output,12345678,13,2) -> 123456.78 The third parameter, said to give the field length to be used, is quite limited: 1) The actual length differs, depending on the presence of a decimal point 2) Length greater than 11 is treated as 11 3) Too short a field leads to corruption of the number, always reserving places for sign and decimal point 3) probably can't be of any use - here's the question if the number should be truncated or replaced by error signs to show that something's wrong. For 1) and 2), there's a possibility that existing programs rely on this behavior. But, as those are 'undocumented "features" ', I feel like they can be replaced by more useful things. Like, fields can be as long as 255 characters, and the number is truly right-aligned, if it has decimals or not. If the number of decimals is greater than the field lengt-1, it is treated as zero. Here's another option to fill: what should be done if both numbers are nearly-equal, equal or the decimals number greater than the field length? Left-aligned, ignoring the field length? Any preferences anyone? Greets, Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/2110995783.3397177.1608638352475%40mail.yahoo.com. -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/AM0PR07MB624109D3F70672AA18669FD7E6DF0%40AM0PR07MB6241.eurprd07.prod.outlook.com.
