Template talk:Roman

(Redirected from Module talk:Roman)
Latest comment: 5 years ago by Soumya-8974 in topic Edit request

Documentation

edit

This template converts Arabic numerals (that is, 1, 2, 3, etc) into Roman numerals (I, II, III etc). It currently works for any whole number between 1 and 4999999. To use it, enter {{Roman|YOURNUMBER}}, replacing "YOURNUMBER" with a number.

Examples of Roman numeral conversion
Arabic Numerals Template Call Roman Numerals
1 {{Roman|1}} I
2 {{Roman|2}} II
49 {{Roman|49}} XLIX
50 {{Roman|50}} L
51 {{Roman|51}} LI
1024 {{Roman|1024}} MXXIV
4999 {{Roman|4999}} IVCMXCIX
5000 {{Roman|5000}} V
5001 {{Roman|5001}} VI
1048576 {{Roman|1048576}} MXLVMMMDLXXVI
7654321 {{Roman|7654321}} N/A
7654321 {{Roman|7654321|No such Roman numerals}} No such Roman numerals


For example, {{Roman|2006}} returns MMVI. Warofdreams talk 22:51, 28 May 2006 (UTC)Reply

With the addition of numbers over 5000 with the macron (here done with tpl:Overline), the current version keeps the macron characters separate from the non-macron characters, and thus uses MMMM rather than MV for 4000. This may be a matter of taste, or it may be something that needs fixing. Dpv 13:00, 11 June 2006 (UTC)Reply

Font-family

edit

I've added a "font" param to the template to allow the serif font to be turned off. It still defaults to "serif", but passing "inherit" will cause it to appear in the same font as the containing text. Mike Dillon 15:24, 3 December 2006 (UTC)Reply

I really needed this to be the default font for what I'm doing. It does look good with serif though. Is there a way to default it to whatever the default is, but give the option of serif? (The opposite of now?) JARED(t)15:38, 3 December 2006 (UTC)Reply
I've just reverted the removal of the font span. Please discuss changes that affect the appearance of templates in widespread use. I may ask to have this template protected because it is in every "year" article (e.g. 2006). Mike Dillon 15:41, 3 December 2006 (UTC)Reply
I don't think changing the default of something already in use in hundreds of articles is reasonable. You can use "font=inherit" for your specific purposes. Mike Dillon 15:42, 3 December 2006 (UTC)Reply

The funny thing is that this was just changed to serif two weeks ago (without discussion). So your suggestion to change it back and have serif an override may be a good one. Mike Dillon 16:39, 3 December 2006 (UTC)Reply

It looks like nearly all of the uses of this template are done through {{Year in other calendars}}. It seems like this template should not have a font-family or a <span> and should be a purely functional conversion template. The {{Year in other calendars}} template is the appropriate place to do font styling, it would seem. Mike Dillon 17:20, 3 December 2006 (UTC)Reply

I've removed the font styling from this template and moved it up to {{Year in other calendars}} to keep this as a purely functional template. I'm going to contact User:AzaToth (the user who added it) to say that I've removed the font styling. Mike Dillon 17:27, 3 December 2006 (UTC)Reply
So I was right all along... haha. JARED(t)17:32, 3 December 2006 (UTC)Reply
It would seem so. Let's hope everyone else agrees ;) Mike Dillon 17:38, 3 December 2006 (UTC)Reply

Protection

edit

I've requested that this page be fully protected because it is esoteric and in widespread use. See Wikipedia:Requests for page protection. Mike Dillon 15:47, 3 December 2006 (UTC)Reply

I appologize if I've brought on this request. I didn't realize how widespread it was. JARED(t)16:24, 3 December 2006 (UTC)Reply
No need to apologize. Protection of widespread templates is not a bad thing. It just means we have to discuss changes before making them. Mike Dillon 16:31, 3 December 2006 (UTC)Reply

The request was not accepted. The template is only used in about 2,000-2,500 articles at the moment, so there isn't much need anyways. Mike Dillon 23:40, 3 December 2006 (UTC)Reply

Edit request

edit

{{editprotected}} Please update {{/doc}} with {{documentation}}. Per Wikipedia:Template documentation/List Thankyou. -- αŁʰƏЩ @ 05:57, 28 April 2008 (UTC)Reply

Done. – Luna Santin (talk) 08:34, 28 April 2008 (UTC)Reply


Extended template

edit

See User:Stelio/Roman for an extended version of this template. That alternative version has the following differences to the current version here (as at 13 March 2009):

  • The alternative version includes handling for fractional values with a precision of 1/1728 (following the rules in Roman numerals).
  • The alternative version avoids the use of 'div' and 'mod' in the mathematical expressions, since their algorithms currently differ from the standard algorithms (see Bugzilla:6068), and their calculation algorithm may therefore potentially be altered in the future.
  • The alternative version renders 4000 as 'IV' as per Roman numerals, as opposed to 'MMMM' as this template currently does.
  • The alternative version handles errors through more detailed messages, rather than returning 'N/A' (and the option to override the error message is still there). A negative argument is treated as an error.
  • The current version produces erroneous results if the argument passed to it is a calculation. For example {{Roman:1+1}} currently returns 'MCXII' rather than 'II'. This can be fixed by wrapping all references to the argument in brackets (so using '({{{1}}})' rather than '{{{1}}}'); the alternative version includes this fix.

-Stelio (talk) 16:35, 13 March 2009 (UTC)Reply

@Stelio: Make it official, this template deserves a jubilation.--Neurorebel (talk) 01:37, 12 June 2017 (UTC)Reply

Subst

edit

I made the template substable - but only the first tranch of numbers. Big numbers will require {{Roman/2}} sorting out. Rich Farmbrough, 23:42, 18 May 2011 (UTC).Reply

{{#time}}

edit

According to mw:Help:Extension:ParserFunctions#.23time {{#time:xrY|...}} parser function can handle numbers between 1 and 3000. Using this might simplify the template. For example {{#time:xrY|2011}} gives MMXI and {{#time:xrY|0011}} gives XI. --Jarekt (talk) 16:05, 7 September 2011 (UTC)Reply

Edit request on 18 December 2012

edit

please update using the current version in the sandbox. a recent change to the "mod" function in the backend software has made this template generate incorrect results. you can clearly see the problem in the testcases. Frietjes (talk) 19:57, 18 December 2012 (UTC)Reply

  Done --Redrose64 (talk) 20:14, 18 December 2012 (UTC)Reply

Template-protected edit request on 23 April 2016

edit

@Mr. Stradivarius, Stelio, and Rich Farmbrough: FYI, I am able to complete these edits myself (Module:Roman is not template-protected). But I wanted to alert template/module folks to take a look at the code and sign-off before I port it.

Changes needed to be made

  1. (Nothing at Template:Roman)
  2. Copy Module:Roman/sandbox code to Module:Roman.
  3. Update the documentation for Roman. Basically, add |fraction=yes support, mention symbols listed at User:Stelio/Roman.
  4. Update the documentation for the Lua if necessary to include some implementation details.
Details on diffs, implementation, and validation

Differences between the live version and the sandbox version (observe Template:Roman/testcases)

  • Sandbox supports 0. Displays as 'N'.
  • Live/sandbox differ on large Romans. (see 4999, 49999, etc) 69105 is LXIXCV in the sandbox version, which mirrors Stelio's version. Live version displays LXVMMMMCV instead.
Different due to new tokens IX and IV being 9000 and 4000 respectively.
  • Sandbox handles decimal, fractional, and arithmetic expressions to a precision of 1/1728 (like Stelio's version). Sandbox uses #expr: at Module:Roman/sandbox line 118.
  • Stelio's version seems incorrect on 0.3333, 0.00347222, 0.9999, 0.41666, 9999/1000, 4999999+1727/1728, etc. In all of these cases, sandbox is either closer to the value, or a simple error/failure to numeralize by Stelio's version. 0.9999 should output like the sandbox does. I don't know why Stelio's version leaves out the little 1/1728 ticks.

How sandbox ensures correct fractional output on tricky cases (0.00001 and 99.99999)

  1. Find the Roman numerals for the integer part of the number.
  2. If the number is not an integer:
    • Add half of the smallest unit (1/1728) to simulate rounding instead of truncation.
    • Ensure this new result is between 1/1728 and 1727/1728. (actually 1.1/1728 and 1727.1/1728 due to floating point rounding issues)
  3. Hence, 0.00001 is guaranteed to have at least the smallest unit symbol (instead of being blank or 0), and 99.99999 does not display as 100 or 99 and 2 halves.

Validation

Please let me know if you have any questions. Thanks.

— Andy W. (talk · contrib) 19:51, 23 April 2016 (UTC)Reply

"The negative number -3299 cannot be converted to Roman numerals" - might it be clearer to say "Negative numbers (such as -3299) cannot be converted to Roman numerals". I.E. make it clear that the negative numbers are out, not just this one or some of them.
All the best: Rich Farmbrough, 20:07, 23 April 2016 (UTC).Reply
@Rich Farmbrough: Were you referring to Stelio's template (which I'm not editing) or the changes I made? Currently, the sandbox version I refer to has no negative message. I could add it if deemed appropriate. — Andy W. (talk · contrib) 20:10, 23 April 2016 (UTC)Reply
Ah, I see. Well I think it appropriate... what do you think? All the best: Rich Farmbrough, 20:27, 23 April 2016 (UTC).Reply
Thanks, this would be something like "if negative then" error("cannot convert negative") or something. @Mr. Stradivarius: or anyone else, is an error message appropriate for how the template is currently being used? Interested in a second opinion. — Andy W. (talk · contrib) 20:47, 23 April 2016 (UTC)Reply

As of now, I'm feeling very confident about simply porting the changes myself, including updating documentation. I'm expecting to make the changes around the end of the month if I hear no reply. If anyone has any comments before the end of this week, let me know. — Andy W. (talk · contrib) 03:18, 25 April 2016 (UTC)Reply

Disabled request as you are not actually requesting a change. It seems to me that you are careful and conscientious enough just to make the change and follow-up with any issues. Regards — Martin (MSGJ · talk) 08:21, 25 April 2016 (UTC)Reply
Thanks, it's done. — Andy W. (talk · contrib) 08:45, 25 April 2016 (UTC)Reply
Thanks for the heads up. (Oh also: good point on the wording of the error message, Rich; I've made that change to my own version even though it won't now be used.) -Stelio (talk) 12:18, 25 April 2016 (UTC)Reply
  • I reverted this edit by Andy M. Wang (talk · contribs). It was causing a big red error message at e.g. 2016: Lua error in Module:Roman at line 119: attempt to call method 'callParserFunction' (a nil value). Clicking that message gives a box headed "Script error" containing:
    Lua error in Module:Roman at line 119: attempt to call method 'callParserFunction' (a nil value).
    
    Backtrace:
    
    1. Module:Roman:119: in function "numToRoman"
    2. Module:Year_in_other_calendars:373: ?
    3. (tail call): ?
    4. mw.lua:511: ?
    
    and I have no idea how to fix it. --Redrose64 (talk) 20:27, 25 April 2016 (UTC)Reply
Addressing this issue now... Thanks for the notice... on first glance, this might have something to do with the parser function {{#time:xrY. I have no idea how to fix this myself at the moment. I've restored much of the code but commented out the line that calls the parser function. — Andy W. (talk · contrib) 20:56, 25 April 2016 (UTC)Reply
@Redrose64: Issue is fixed. Special:Diff/717026907/717124504. We're using a safer pcall (similar to the edit request made to Module math here) and everything seems to be okay now. — Andy W. (talk · contrib) 21:33, 25 April 2016 (UTC)Reply
  Thank you --Redrose64 (talk) 22:41, 25 April 2016 (UTC)Reply

Good work! All the best: Rich Farmbrough, 23:57, 4 May 2016 (UTC).Reply

Negative Numbers

edit
Handle negative with an "m" example: -1521=mMDXXI
before the - sign existed an m was used. — Preceding unsigned comment added by Neurorebel (talkcontribs) 01:47, 12 June 2017 (UTC)Reply

For discussion: Neurorebel is suggesting that the template should be extended to allow for negative numbers. And that the way to do this is by using an "m" prefix. Some more commentary here. -Stelio (talk) 12:30, 16 June 2017 (UTC)Reply

I would support this. All the best: Rich Farmbrough, 11:07, 28 July 2017 (UTC).Reply
This could affect things if my edit is picked up—things would potentially be unclear if 'mdccc' is taken as input—would need to check case of input if all lowercase then must ignore and not take 'm' as negative sign? Trivial to work around but should likely specify behavior in docASiplas (talk) 09:38, 20 February 2018 (UTC)Reply

Roman → Arabic

edit

See Module:ConvertNumeric's roman_to_numeral

Was Duplicate of Module:Convert—Withdrawn
  Question: would it not be more intuitive to create a different template to do the conversion the other way round? — Martin (MSGJ · talk) 20:51, 20 February 2018 (UTC).Reply
First intuition was {{Arabic}} as template for new module but that was taken… Ideas on something just as apt? Seemed logical second choice to add to {{Roman}} at that point. Would be happy to rewrite some more efficient code under a new name; main focus is driving use to help minimize transcription errors and best name is part of that whether that's Roman or not. –ASiplas (talk) 21:30, 20 February 2018 (UTC)Reply
@MSGJ: this I see is duplicate of Module:ConvertNumeric going to Revert Module:Roman/sandbox and Module:Roman/docASiplas (talk) 21:57, 20 February 2018 (UTC)Reply

Feature request: hovertext with arabic numerals

edit

I think the title is pretty self-explanatory, and this could be implemented as a flag, e.g. {{roman|784|hover=on}} would display as DCCLXXXIV, which would be functionally equivalent to <abbr title="784">{{roman|784}}</abbr>.-Ich (talk) 07:54, 13 August 2018 (UTC)Reply


Edit request

edit

The ƻ is wrong in the fractions, albeit for a decent reason: There's a system of reversing characters in place, but the most correct character, 𐆔 has basically no support. But we can do far, far better in a very simple way: We should replace ƻ with Ƨ

a.k.a. <s>Ƨ</s> by simple search-replace substitution. I'll admit, I'm not good with modern lua-y templates, so can't say where the thing is. Adam Cuerden (talk) 23:23, 2 November 2018 (UTC)Reply

This is on line 80 of Module:Roman. — xaosflux Talk 16:00, 3 November 2018 (UTC)Reply

Edit request

edit
  Moved from Module talk:Roman

According to the article Roman numerals, ancient Romans used Є· for 1/8. Can this particular numeral be added?

—Yours sincerely, Soumyabrata 17:55, 12 July 2019 (UTC)Reply