4 #include "base/cl_sysdep.h"
7 #include "real/format-output/cl_format.h"
12 #include "cln/integer.h"
16 static const char * const cl_format_ordinal_ones [20] = {
39 static const char * const cl_format_ordinal_tens [10] = {
52 void format_ordinal (std::ostream& stream, const cl_I& argument)
55 fprint(stream,"zeroth");
57 var cl_I arg = argument;
59 fprint(stream,"minus ");
62 var cl_I_div_t div = floor2(arg,100);
63 var const cl_I& hundreds = div.quotient;
64 var uintL tens_and_ones = cl_I_to_UL(div.remainder);
66 format_cardinal(stream,hundreds*100);
67 if (tens_and_ones == 0)
70 var uintL tens = floor(tens_and_ones,10);
71 var uintL ones = tens_and_ones % 10;
73 fprintchar(stream,' ');
75 fprint(stream,cl_format_ordinal_ones[tens_and_ones]);
77 fprint(stream,cl_format_ordinal_tens[tens]);
79 fprint(stream,cl_format_tens[tens]);
80 fprintchar(stream,'-');
81 fprint(stream,cl_format_ordinal_ones[ones]);