@ 2017-10-02T23:34:12Z <?php
/*
|-----------------------------------------------------------------------------------------------------------------------
| Negative roman numbers?! :D - No apparent concept of negatives here.
| So we could just stick to normal negative numbers.
|-----------------------------------------------------------------------------------------------------------------------
*/
# normal negative numbers
$roman = '-x: =#,##0=;';
# "Just for fun/Unofficial" negative roman numerals
#$roman = '-x: ->>;';
/*
|-----------------------------------------------------------------------------------------------------------------------
| No concept of zero here.
| The number zero does not have its own Roman numeral, but the word nulla (the Latin word meaning "none")
| was used by medieval scholars in lieu of 0. Dionysius Exiguus was known to use nulla alongside Roman numerals
| in 525.
|
| 0: nulla
| 0: N
| The N could also be used. https://en.wikipedia.org/wiki/Roman_numerals#Zero
|-----------------------------------------------------------------------------------------------------------------------
*/
# $roman = '0: N;';
$roman .= '0: nulla;';
/*
|-----------------------------------------------------------------------------------------------------------------------
| The larger numbers
|-----------------------------------------------------------------------------------------------------------------------
*/
$roman .= <<<RULE_BASED_FORMAT
I; II; III; IV; V; VI; VII; VIII; IX;
10: X>>;
20: XX>>;
30: XXX>>;
40: XL>>;
50: L>>;
60: LX>>;
70: LXX>>;
80: LXXX>>;
90: XC>>;
100: C>>;
400: CD>>;
500: D>>;
600: DC>>;
900: CM>>;
1000: M>>;
2000: MM>>;
3000: MMM>>;
4000: MMMM>>;
RULE_BASED_FORMAT;
/*
|-----------------------------------------------------------------------------------------------------------------------
| The larger numbers
|-----------------------------------------------------------------------------------------------------------------------
*/
$roman .= <<<RULE_BASED_FORMAT
5000: V\u{0305}>>;
6000: V\u{0305}M>>;
7000: V\u{0305}MM>>;
8000: V\u{0305}MMM>>;
9000: V\u{0305}MMMM>>;
10000: X\u{0305}>>;
20000: X\u{0305}X\u{0305}>>;
30000: X\u{0305}X\u{0305}X\u{0305}>>;
40000: X\u{0305}L\u{0305}>>;
50000: L\u{0305}>>;
60000: L\u{0305}X\u{0305}>>;
70000: L\u{0305}X\u{0305}X\u{0305}>>;
80000: L\u{0305}X\u{0305}X\u{0305}X\u{0305}>>;
90000: X\u{0305}C\u{0305}>>;
100000: C\u{0305}>>;
200000: C\u{0305}C\u{0305}>>;
300000: C\u{0305}C\u{0305}C\u{0305}>>;
400000: C\u{0305}D\u{0305}>>;
500000: D\u{0305}>>;
600000: D\u{0305}C\u{0305}>>;
700000: D\u{0305}C\u{0305}C\u{0305}>>;
800000: D\u{0305}C\u{0305}C\u{0305}C\u{0305}>>;
900000: C\u{0305}M\u{0305}>>;
1000000: M\u{0305}>>;
2000000: M\u{0305}M\u{0305}>>;
3000000: M\u{0305}M\u{0305}M\u{0305}>>;
4000000: I\u{033F}V\u{033F}>>;
5000000: V\u{033F}>>;
6000000: V\u{033F}I\u{033F}>>;
7000000: V\u{033F}I\u{033F}I\u{033F}>>;
8000000: V\u{033F}I\u{033F}I\u{033F}I\u{033F}>>;
9000000: I\u{033F}X\u{033F}>>;
10000000: X\u{033F}>>;
20000000: X\u{033F}X\u{033F}>>;
30000000: X\u{033F}X\u{033F}X\u{033F}>>;
40000000: X\u{033F}L\u{033F}>>;
50000000: L\u{033F}>>;
60000000: L\u{033F}X\u{033F}>>;
70000000: L\u{033F}X\u{033F}X\u{033F}>>;
80000000: L\u{033F}X\u{033F}X\u{033F}X\u{033F}>>;
90000000: X\u{033F}C\u{033F}>>;
100000000: C\u{033F}>>;
200000000: C\u{033F}C\u{033F}>>;
300000000: C\u{033F}C\u{033F}C\u{033F}>>;
400000000: C\u{033F}D\u{033F}>>;
500000000: D\u{033F}>>;
600000000: D\u{033F}C\u{033F}>>;
700000000: D\u{033F}C\u{033F}C\u{033F}>>;
800000000: D\u{033F}C\u{033F}C\u{033F}C\u{033F}>>;
900000000: C\u{033F}M\u{033F}>>;
1000000000: M\u{033F}>>;
2000000000: M\u{033F}M\u{033F}>>;
3000000000: M\u{033F}M\u{033F}M\u{033F}>>;
4000000000: M\u{033F};M\u{033F};M\u{033F};M\u{033F}>>;
RULE_BASED_FORMAT;
/*
|-----------------------------------------------------------------------------------------------------------------------
| Then go back to normal numbers
|-----------------------------------------------------------------------------------------------------------------------
*/
$roman .= <<<RULE_BASED_FORMAT
5000000000: =#,##0=;
RULE_BASED_FORMAT;
header('Content-Type: text/html; charset=utf-8');
$fmt = new NumberFormatter('en', NumberFormatter::PATTERN_RULEBASED, $roman);
$year = $fmt->format(2014);
$game = $fmt->format(22);
echo "Year $year, $game Olympic Winter Games";
/*
|-----------------------------------------------------------------------------------------------------------------------
| Sources:
| https://en.wikipedia.org/wiki/Roman_numerals
| http://www.tuomas.salste.net/doc/roman/numeri-romani-learn.html
| https://en.wikipedia.org/wiki/1,000,000,000
| https://forbrains.co.uk/free_online_tools/convert_to_roman_numerals
| https://en.wikipedia.org/wiki/Numerals_in_Unicode#Roman_numerals_in_Unicode
| http://userguide.icu-project.org/formatparse/numbers/rbnf-examples
|
| Warning, there are more than one ways to write certain numbers, and some
| can even mean two different numbers.
|
| Example: "V̅I̅I̅I̅" can mean 80,000 or 800,000
| See https://en.wikipedia.org/wiki/Roman_numerals#Vinculum
|-----------------------------------------------------------------------------------------------------------------------
*/
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.24 , 7.1.0 - 7.1.20 , 7.2.6 - 7.2.33 , 7.3.16 - 7.3.31 , 7.4.0 - 7.4.32 , 8.0.0 - 8.0.12 , 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Year MMXIV, XXII Olympic Winter Games Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Year MMXIV, XXII Olympic Winter Games Output for 8.0.13 Fatal error: Uncaught Error: Class "NumberFormatter" not found in /in/mKXqg:130
Stack trace:
#0 {main}
thrown in /in/mKXqg on line 130
Process exited with code 255 . Output for 7.3.32 - 7.3.33 , 7.4.33 Fatal error: Uncaught Error: Class 'NumberFormatter' not found in /in/mKXqg:130
Stack trace:
#0 {main}
thrown in /in/mKXqg on line 130
Process exited with code 255 . preferences:dark mode live preview
172.29 ms | 401 KiB | 178 Q