POV-Ray : Newsgroups : povray.text.scene-files : Roman numerals : Re: Roman numerals Server Time
21 Dec 2025 04:25:21 EST (-0500)
  Re: Roman numerals  
From: kurtz le pirate
Date: 20 Dec 2025 11:47:22
Message: <6946d31a$1@news.povray.org>
On 20/12/2025 13:27, jr wrote:
> hi,
> 
> kurtz le pirate <kur### [at] freefr> wrote:
>> On 20/12/2025 00:16, jr wrote:
>>> I wrote/"needed" a macro ('LatinYear()') ...
> 
>> Good work, a little too complicated, but good work.
> 
> thank you, very much.  you're right, of course.  attached an update, less
> "cruft" :-).  also I got rid of the '#for', and the macro can now be used with
> version 3.7 too (tested with v3.7.0.8).
> 
> 
> enjoy, jr.

what do you think of this version?


// --- macro start
#macro ToRoman(DecimalToConvert)
  #local Nb = 13;
  #local values = array[Nb] {1000,900,500,400,100,90,50,40,10,9,5,4,1};
  #local symbols = array[Nb] 
{"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
  #local roman = "";
  #local num = DecimalToConvert;
  #local i = 0;
  #while ( i<Nb & num>0 )
   #while( values[i] <= num )
    #local num = num - values[i];
    #local roman = concat(roman,symbols[i]);
   #end
   #local i = i + 1;
  #end
  roman
#end
// --- macro end


#declare D = 10191; // beginning of the Dune Story
#declare R = ToRoman(D);
#debug concat(str(D,0,0)," -> ",R,"\n")




...of course, valid only for positive years.



-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.