Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Roman/doc: Difference between revisions

From Neodyland Wiki
No edit summary
Update documentation
Line 29: Line 29:
Usage:
Usage:
: <code>roman_value = roman._Numeral(value)</code>
: <code>roman_value = roman._Numeral(value)</code>
=== isRoman ===
Tests if the input is a valid Roman numeral.  Returns true if so, false if not.  For the purposes of this function, the empty string is not a Roman numeral.
Usage:
: <code>if roman. isRoman(roman_value) then</code>
=== toArabic ===
This function converts a Roman numeral into an Arabic numeral.  It works for values between 0 and 4999999.  The empty string is converted to zero. If the input is not a valid Roman numeral this function return zero.
Usage:
: <code>arabic_value = roman.toArabic(value)</code>


==See Also==
==See Also==
{{collapse|title=Modules related to internationalization (i18n) of dates|1={{DateRelatedModules}}}}
{{collapse|title=Modules related to internationalization (i18n) of dates|1={{DateRelatedModules}}}}

Revision as of 08:57, 9 January 2015

Summary

This module contains functions for working with Roman numerals. Currently used by:

Using this module from templates

Numeral

This function converts an Arabic numeral into a Roman numeral. It works for values between 0 and 4999999. The output string may contain HTML tags. Arabic numeral zero is output as an empty string. If the input does not look like it contains a number or the number is outside of the supported range an error message is returned. If an error message is returned, the error message will contain code to categorize pages into Category:Errors reported by Module Roman.

Usage:

{{#invoke:Roman|Numeral|value}}

Example:

{{#invoke:Roman|Numeral|8}} produces VIII

Using this module from Lua code

In order to use the functions in this module from another Lua module you first have to import this module.

Example:

local roman = require('Module:Roman')

_Numeral

This function converts an Arabic numeral into a Roman numeral. It works for values between 0 and 4999999. The output string may contain HTML tags. Arabic numeral zero is output as an empty string. If the input does not look like it contains a number or the number is outside of the supported range an error message is returned. If an error message is returned, the error message will contain code to categorize pages into Category:Errors reported by Module Roman.

Usage:

roman_value = roman._Numeral(value)

isRoman

Tests if the input is a valid Roman numeral. Returns true if so, false if not. For the purposes of this function, the empty string is not a Roman numeral.

Usage:

if roman. isRoman(roman_value) then

toArabic

This function converts a Roman numeral into an Arabic numeral. It works for values between 0 and 4999999. The empty string is converted to zero. If the input is not a valid Roman numeral this function return zero.

Usage:

arabic_value = roman.toArabic(value)


See Also

Modules related to internationalization (i18n) of dates
Template:DateRelatedModules
Cookies help us deliver our services. By using our services, you agree to our use of cookies.