Convert numbers to words
Over the course of my career, I've used a lot of programming languages. When learning a new language, I like to have a project to work on that exposes me to the nuances of the language. The numwords
class is one of my favorite exercises for this purpose. I have written it in dozens of languages over the years, including several times in C and C++.
numwords
is a class that spells out a number in words. It can be useful for banking and accounting applications. It looks like this in use:
int main() { bw::numword nw{}; uint64_t n; nw = 3; bw::print("n is {}, {}\n", nw.getnum(), nw); nw = 47; bw::print("n is {}, {}\n", nw.getnum(), nw); n = 100073; bw::print("n is {}, {}\n", n, bw::numword{n}); n = 1000000001; bw::print("n is {}, {}\n"...