@ 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.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.006 0.016 20.68 8.3.5 0.014 0.007 20.42 8.3.4 0.003 0.013 20.40 8.3.3 0.012 0.003 20.47 8.3.2 0.000 0.008 21.84 8.3.1 0.003 0.006 23.59 8.3.0 0.003 0.006 23.52 8.2.18 0.034 0.006 18.63 8.2.17 0.008 0.008 22.96 8.2.16 0.009 0.006 23.79 8.2.15 0.008 0.000 24.18 8.2.14 0.008 0.000 24.66 8.2.13 0.005 0.003 23.31 8.2.12 0.003 0.006 26.35 8.2.11 0.006 0.003 23.07 8.2.10 0.004 0.008 20.16 8.2.9 0.000 0.010 19.88 8.2.8 0.000 0.008 20.36 8.2.7 0.003 0.006 19.75 8.2.6 0.009 0.005 19.74 8.2.5 0.000 0.008 19.75 8.2.4 0.009 0.004 20.90 8.2.3 0.004 0.004 20.91 8.2.2 0.008 0.000 20.21 8.2.1 0.003 0.005 20.23 8.2.0 0.007 0.003 20.22 8.1.28 0.012 0.003 25.92 8.1.27 0.000 0.008 23.40 8.1.26 0.004 0.004 26.35 8.1.25 0.009 0.000 28.09 8.1.24 0.004 0.007 23.22 8.1.23 0.009 0.003 23.11 8.1.22 0.008 0.000 20.32 8.1.21 0.006 0.003 19.36 8.1.20 0.006 0.003 19.35 8.1.19 0.009 0.004 19.22 8.1.18 0.008 0.000 19.25 8.1.17 0.005 0.005 20.71 8.1.16 0.000 0.009 20.47 8.1.15 0.004 0.004 21.65 8.1.14 0.005 0.003 19.81 8.1.13 0.004 0.004 20.56 8.1.12 0.005 0.003 19.54 8.1.11 0.000 0.008 19.70 8.1.10 0.004 0.004 19.71 8.1.9 0.000 0.008 19.63 8.1.8 0.004 0.004 19.70 8.1.7 0.003 0.005 19.69 8.1.6 0.003 0.005 19.74 8.1.5 0.004 0.004 19.42 8.1.4 0.003 0.005 19.73 8.1.3 0.004 0.004 19.68 8.1.2 0.005 0.003 19.81 8.1.1 0.005 0.003 19.84 8.1.0 0.000 0.010 19.87 8.0.30 0.009 0.004 18.77 8.0.29 0.005 0.005 18.63 8.0.28 0.000 0.009 20.06 8.0.27 0.004 0.004 19.22 8.0.26 0.004 0.004 20.57 8.0.25 0.000 0.007 19.11 8.0.24 0.000 0.009 18.94 8.0.23 0.004 0.004 18.88 8.0.22 0.005 0.003 18.96 8.0.21 0.000 0.008 18.96 8.0.20 0.000 0.007 18.87 8.0.19 0.004 0.004 19.07 8.0.18 0.006 0.003 19.02 8.0.17 0.004 0.004 19.03 8.0.16 0.004 0.004 18.86 8.0.15 0.000 0.008 18.82 8.0.14 0.000 0.009 19.09 8.0.13 0.003 0.003 13.43 8.0.12 0.003 0.005 19.23 8.0.11 0.000 0.008 19.13 8.0.10 0.000 0.008 19.11 8.0.9 0.000 0.008 19.26 8.0.8 0.006 0.009 18.98 8.0.7 0.008 0.000 19.27 8.0.6 0.000 0.008 19.14 8.0.5 0.004 0.004 19.30 8.0.3 0.011 0.010 19.36 8.0.2 0.012 0.010 19.29 8.0.1 0.003 0.006 19.35 8.0.0 0.009 0.009 18.95 7.4.33 0.000 0.004 15.55 7.4.32 0.006 0.000 18.83 7.4.30 0.004 0.007 18.68 7.4.29 0.014 0.004 18.82 7.4.28 0.000 0.008 18.63 7.4.27 0.007 0.000 18.80 7.4.26 0.011 0.007 18.58 7.4.25 0.004 0.004 18.84 7.4.24 0.000 0.007 18.85 7.4.23 0.000 0.007 18.80 7.4.22 0.007 0.014 18.55 7.4.21 0.012 0.009 18.63 7.4.20 0.005 0.003 18.61 7.4.16 0.010 0.011 18.79 7.4.15 0.012 0.006 18.55 7.4.14 0.010 0.009 18.57 7.4.13 0.009 0.016 18.72 7.4.12 0.009 0.011 18.75 7.4.11 0.011 0.008 18.43 7.4.10 0.010 0.013 18.74 7.4.9 0.006 0.012 18.50 7.4.8 0.012 0.011 19.39 7.4.7 0.003 0.017 18.56 7.4.6 0.007 0.010 18.64 7.4.5 0.012 0.002 18.71 7.4.4 0.009 0.009 18.39 7.4.3 0.008 0.008 18.74 7.4.0 0.003 0.013 17.53 7.3.33 0.003 0.003 13.13 7.3.32 0.000 0.005 13.15 7.3.31 0.004 0.004 18.45 7.3.30 0.000 0.008 18.41 7.3.29 0.013 0.008 18.41 7.3.28 0.008 0.009 18.43 7.3.27 0.007 0.010 18.34 7.3.26 0.011 0.009 18.51 7.3.25 0.009 0.010 18.63 7.3.24 0.009 0.009 18.50 7.3.23 0.007 0.011 18.62 7.3.21 0.011 0.007 18.67 7.3.20 0.015 0.003 18.33 7.3.19 0.006 0.011 18.64 7.3.18 0.014 0.004 18.79 7.3.17 0.011 0.013 18.50 7.3.16 0.004 0.014 18.50 7.2.33 0.007 0.011 18.79 7.2.32 0.006 0.012 18.91 7.2.31 0.014 0.004 18.56 7.2.30 0.007 0.012 18.37 7.2.29 0.003 0.015 18.48 7.2.6 0.007 0.007 19.00 7.1.20 0.004 0.011 18.31 7.1.10 0.011 0.011 20.51 7.1.9 0.015 0.006 20.35 7.1.8 0.015 0.006 20.45 7.1.7 0.015 0.006 19.25 7.1.6 0.025 0.019 37.25 7.1.5 0.032 0.013 37.18 7.1.4 0.029 0.015 36.96 7.1.3 0.023 0.026 37.17 7.1.2 0.033 0.015 36.78 7.1.1 0.000 0.023 18.79 7.1.0 0.011 0.011 18.92 7.0.24 0.009 0.016 20.00 7.0.23 0.012 0.009 20.01 7.0.22 0.013 0.009 20.11 7.0.21 0.007 0.013 18.91 7.0.20 0.017 0.003 19.07 7.0.19 0.013 0.009 18.98 7.0.18 0.006 0.015 18.39 7.0.17 0.011 0.011 18.51 7.0.16 0.011 0.014 18.63 7.0.15 0.009 0.012 18.73 7.0.14 0.003 0.014 18.72 7.0.13 0.016 0.005 18.89 7.0.12 0.016 0.006 18.76 7.0.11 0.006 0.015 18.50 7.0.10 0.011 0.011 18.39 7.0.9 0.006 0.016 18.30 7.0.8 0.006 0.016 18.37 7.0.7 0.009 0.014 18.41 7.0.6 0.006 0.016 18.43 7.0.5 0.003 0.016 18.55 7.0.4 0.009 0.009 18.29 7.0.3 0.003 0.017 18.42 7.0.2 0.007 0.009 18.52 7.0.1 0.007 0.013 18.38 7.0.0 0.015 0.007 18.51
preferences:dark mode live preview
32.49 ms | 400 KiB | 5 Q