POV-Ray : Newsgroups : povray.text.scene-files : Roman numerals Server Time
21 Dec 2025 04:25:23 EST (-0500)
  Roman numerals (Message 1 to 7 of 7)  
From: jr
Subject: Roman numerals
Date: 19 Dec 2025 18:20:00
Message: <web.6945dcb042cb8f7352af7e976cde94f1@news.povray.org>
hi,

I wrote/"needed" a macro ('LatinYear()') to convert years to their Roman
numerals representation, posting it .. just in case.  the macro takes the year
and returns a string, for instance:

#version 3.8;
global_settings {assumed_gamma 1}

#include "latinum.inc"

#debug concat("2000  ",LatinYear(2000),".\n")
#debug concat("1984  ",LatinYear(1984),".\n")
#debug concat("2026  ",LatinYear(2026),".\n")


enjoy, jr.


Post a reply to this message


Attachments:
Download 'latinum.inc.txt' (3 KB)

From: kurtz le pirate
Subject: Re: Roman numerals
Date: 20 Dec 2025 05:23:25
Message: <6946791d$1@news.povray.org>
On 20/12/2025 00:16, jr wrote:
> hi,
> 
> I wrote/"needed" a macro ('LatinYear()') to convert years to their Roman
> numerals representation, posting it .. just in case.  the macro takes the year
> and returns a string, for instance:
> 
> #version 3.8;
> global_settings {assumed_gamma 1}
> 
> #include "latinum.inc"
> 
> #debug concat("2000  ",LatinYear(2000),".\n")
> #debug concat("1984  ",LatinYear(1984),".\n")
> #debug concat("2026  ",LatinYear(2026),".\n")
> 
> 
> enjoy, jr.

Hi,

Good work, a little too complicated, but good work.





-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

From: jr
Subject: Re: Roman numerals
Date: 20 Dec 2025 07:30:00
Message: <web.6946962b6fb404d152af7e976cde94f1@news.povray.org>
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.


Post a reply to this message


Attachments:
Download 'latinum.inc.txt' (3 KB)

From: Bald Eagle
Subject: Re: Roman numerals
Date: 20 Dec 2025 09:25:00
Message: <web.6946b1256fb404d11f9dae3025979125@news.povray.org>
This is quite synchronicitous - I was just musing about doing Roman Numerals the
other day.

Chalked it up to "add to to do list", and "surely someone else has done this
before".  And promptly got interrupted with something else to do.


Not sure if this helps any - read the last sentence:

https://wiki.povray.org/content/Documentation_Talk:Reference_Section_2.3

- BE


Post a reply to this message

From: kurtz le pirate
Subject: Re: Roman numerals
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

From: Alain Martel
Subject: Re: Roman numerals
Date: 20 Dec 2025 12:31:06
Message: <6946dd5a$1@news.povray.org>
Le 2025-12-20 à 11:47, kurtz le pirate a écrit :
> 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.
Just use the absolute value of the year and add «BCE» for the negative 
years.
-2027 → MMXXVII BCE

Now, need a font supporting macron for years 1 000 000 to 999 999 999. 
And double macron for years 1 000 000 000 to 999 999 999 999.


Post a reply to this message

From: jr
Subject: Re: Roman numerals
Date: 20 Dec 2025 17:55:00
Message: <web.694728d36fb404d152af7e976cde94f1@news.povray.org>
hi,

kurtz le pirate <kur### [at] freefr> wrote:
> ...
> what do you think of this version?
> ...

several things.  </grin>  first, it was fun to compare (thanks) and find the old
"swings and roundabouts" adage confirmed.

it is pretty neat, the all-in-one macro.  pretty compact too.  (too small to
merit an include file </facetious-grin>)  not having a "mathematical brain" I
found your code "amazing" but not as "obvious" as the method/algorithm provided
by Wikipedia.  also, it comes at a cost.  when running each macro ~20k times (5
loops over 1-3999 range) the nested loops are a little more "expensive".


regards, jr.


Post a reply to this message

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