12 #include "cln/integer.h"
13 #include "cln/integer_io.h"
14 #include "cln/abort.h"
18 void format_old_roman (cl_ostream stream, const cl_I& arg)
20 if (!(0 < arg && arg < 5000)) {
21 fprint(stderr, "format_old_roman: argument should be in the range 1 - 4999, not ");
23 fprint(stderr, ".\n");
26 var uintL value = cl_I_to_UL(arg);
27 struct roman { char symbol; uintL value; };
28 static const roman scale[7] = {
37 for (int i = 6; value > 0 /* && i >= 0 */ ; i--) {
38 var const roman * p = &scale[i];
39 var uintL multiplicity = floor(value,p->value);
40 value = value % p->value;
41 while (multiplicity > 0) {
42 fprintchar(stream,p->symbol);