POV-Ray : Newsgroups : povray.text.scene-files : Roman numerals Server Time
25 Dec 2025 14:02:37 EST (-0500)
  Roman numerals (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
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

From: kurtz le pirate
Subject: Re: Roman numerals
Date: 21 Dec 2025 05:47:15
Message: <6947d033$1@news.povray.org>
On 20/12/2025 23:53, jr wrote:
> 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".


20K is a lot, and double loops can be detrimental. You're right.


In fact, a long time ago, I was developing applications with FileMaker 
and I had the same need. I just found my function and converted it to 
POV SDL. Juste for fun ;)




-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

From: jr
Subject: Re: Roman numerals
Date: 21 Dec 2025 07:35:00
Message: <web.6947e88e6fb404d152af7e976cde94f1@news.povray.org>
hi,

kurtz le pirate <kur### [at] freefr> wrote:
> ...
> 20K is a lot, and double loops can be detrimental. You're right.

agree, unrealistic (I only wanted to get a(n approximate) "feel").


> In fact, a long time ago, I was developing applications with FileMaker
> and I had the same need. I just found my function and converted it to
> POV SDL. Juste for fun ;)

and that last is key.  last night I remembered that POV-Ray permits nested macro
declarations/definitions, and (fwiw) attach a text file with the code as adapted
"over breakfast" :-).  cheers.


regards, jr.


Post a reply to this message


Attachments:
Download 'forfun.txt' (2 KB)

From: kurtz le pirate
Subject: Re: Roman numerals
Date: 23 Dec 2025 11:59:29
Message: <694aca71$1@news.povray.org>
On 21/12/2025 13:32, jr wrote:
> hi,
> 
> kurtz le pirate <kur### [at] freefr> wrote:
>> ...
>> 20K is a lot, and double loops can be detrimental. You're right.
> 
> agree, unrealistic (I only wanted to get a(n approximate) "feel").
> 

for 20000 converts :
  * Elapsed time = 0.0202 ms for my macro
  * Elapsed time = 0.0162 ms for yours

you're the winner.


;)

-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

From: Bald Eagle
Subject: Re: Roman numerals
Date: 24 Dec 2025 16:10:00
Message: <web.694c56586fb404d1b3c316ba25979125@news.povray.org>


Post a reply to this message


Attachments:
Download 'aa1ec1ml.jpg' (16 KB)

Preview of image 'aa1ec1ml.jpg'
aa1ec1ml.jpg


 

From: kurtz le pirate
Subject: Re: Roman numerals
Date: 25 Dec 2025 03:26:34
Message: <694cf53a$1@news.povray.org>
On 24/12/2025 22:08, Bald Eagle wrote:
> 
> 
EXCELLENT




-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

From: jr
Subject: Re: Roman numerals
Date: 25 Dec 2025 09:55:00
Message: <web.694d4f696fb404d152af7e976cde94f1@news.povray.org>
hi.

oh man, beautiful.  thank you, very much.


regards, jr.


Post a reply to this message

From: jr
Subject: Re: Roman numerals
Date: 25 Dec 2025 09:55:00
Message: <web.694d4f766fb404d152af7e976cde94f1@news.povray.org>
hi,

kurtz le pirate <kur### [at] freefr> wrote:
On 21/12/2025 13:32, jr wrote:
> > ...
> > agree, unrealistic (I only wanted to get a(n approximate) "feel").
>
> for 20000 converts :
>   * Elapsed time = 0.0202 ms for my macro
>   * Elapsed time = 0.0162 ms for yours
>
> you're the winner.
> ;)

</LOLz>  truly, "I've won" because I feel that thanks to your inputs my macro
got better as a result.  cheers.


regards, jr.


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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