/* latinum.inc * * the LatinYear() macro converts small integer values (1,..,3999) to their * representation in Roman Numerals, as described in the Wikipedia page. * the macro takes an integer argument and expands to a string. * * Persistence of Vision Raytracer version 3.8 or later. * * * * version: 202512.1 */ #ifndef (ltny__include_temp) #declare ltny__include_temp = version; #version 3.8; #ifdef (View_POV_Include_Stack) #debug "including 'latinum.inc'\n" #end /* ------------------------------------------------------------------------- */ #macro ltny__lkup(l_) #local s_ = ""; #for (i_,1,3) #local s_ = concat(s_,l_); #end s_ #end #macro ltny__mille(dgt_) #local n_ = val(dgt_); substr("MMM",1,n_) #end #macro ltny__cvt(dgt_, s1_, s5_, s10_) #local n_ = val(dgt_); #switch(n_) #case(0) #local s_ = ""; #break #range(1,3) #local s_ = substr(ltny__lkup(s1_),1,n_); #break #case(4) #local s_ = concat(s1_,s5_); #break #case(5) #local s_ = s5_; #break #range(6,8) #local s_ = concat(s5_,substr(ltny__lkup(s1_),1,n_-5)); #break #case(9) #local s_ = concat(s1_,s10_); #break #else #error "oops, \"cannot happen\" error in '__cvt()'." #end s_ #end #macro ltny__convert() #local s_ = ""; #switch (strlen(ystr_)) #case(4) #local s_ = concat(ltny__mille(substr(ystr_,1,1)), ltny__cvt(substr(ystr_,2,1),"C","D","M"), ltny__cvt(substr(ystr_,3,1),"X","L","C"), ltny__cvt(substr(ystr_,4,1),"I","V","X")); #break #case(3) #local s_ = concat(ltny__cvt(substr(ystr_,1,1),"C","D","M"), ltny__cvt(substr(ystr_,2,1),"X","L","C"), ltny__cvt(substr(ystr_,3,1),"I","V","X")); #break #case(2) #local s_ = concat(ltny__cvt(substr(ystr_,1,1),"X","L","C"), ltny__cvt(substr(ystr_,2,1),"I","V","X")); #break #case(1) #local s_ = ltny__cvt(ystr_,"I","V","X"); #break #else #error "oops, \"cannot happen\" error in '__convert()'." #end s_ #end #macro LatinYear(year_) #if (int(year_) != year_) #error "oops, bad 'year'." #elseif (year_ < 1 | 3999 < year_) #error "oops, out-of-range 'year'." #end #local ystr_ = str(year_,0,0); ltny__convert() #end #version ltny__include_temp; #end /* -------------------------------------------------------------------- * * the content above is covered by the GNU General Public License v3+ * * copyright (c) 2025 jr . * * all rights reserved. * * -------------------------------------------------------------------- */