August 14, 2021 03:34 pm
Original Link: http://rss.slashdot.org/~r/Slashdot/slashdot/~3/nAX_usyOl6k/ask-slashdot-is-there-a-standard-way-of-formatting-numbers
Ask Slashdot: Is There a 'Standard' Way of Formatting Numbers?
Long-time Slashdot reader Pieroxy is working on a new open source project, a web-based version of the system-monitoring software Conky. The ultimate goal is send the data to an HTML interface "to find some use for the old iPads/tablets/laptops we all have lying around. You can put them next to your screen and have your metrics displayed there...!" There's just one problem: "I had to come up with a way for users to format a number."I needed a small string the user could write to describe exactly what they want to do with their number. Some examples can be: write it as a 3-digit number suffixed by SI prefixes when the numbers are too big or too small, display a timestamp as HH:MM string, or just the day of week, eventually cut to the first three characters, do the same with a timestamp in milliseconds, or nanoseconds, display a nice string out of a number of seconds to express a duration ("3h 12mn 17s"), pad the number with spaces so that all numbers are aligned (left or right), force a fixed number of digits after the decimal point, etc. In other words, I was looking for a "universal" way of formatting numbers and failed to find any kind of standard online. Do Slashdot readers know of such a thing or should I create my own?Read more of this story at Slashdot.
Original Link: http://rss.slashdot.org/~r/Slashdot/slashdot/~3/nAX_usyOl6k/ask-slashdot-is-there-a-standard-way-of-formatting-numbers
Share this article:
Tweet
View Full Article
Slashdot
Slashdot was originally created in September of 1997 by Rob "CmdrTaco" Malda. Today it is owned by Geeknet, Inc..More About this Source Visit Slashdot