12 #include "cl_integer.h"
13 #include "cl_integer_io.h"
16 void format_old_roman (cl_ostream stream, const cl_I& arg)
18 if (!(0 < arg && arg < 5000)) {
19 fprint(cl_stderr, "format_old_roman: argument should be in the range 1 - 4999, not ");
20 fprint(cl_stderr, arg);
21 fprint(cl_stderr, ".\n");
24 var uintL value = cl_I_to_UL(arg);
25 struct roman { char symbol; uintL value; };
26 static const roman scale[7] = {
35 for (int i = 6; value > 0 /* && i >= 0 */ ; i--) {
36 var const roman * p = &scale[i];
37 var uintL multiplicity = floor(value,p->value);
38 value = value % p->value;
39 while (multiplicity > 0) {
40 fprintchar(stream,p->symbol);