wandersonwhcr / romans

A Simple PHP Roman Numerals Library
MIT License
44 stars 3 forks source link

Large numbers #40

Open marcortola opened 6 years ago

marcortola commented 6 years ago

There may be cases where a large arabic number needs to be converted to a roman number. Should we implement that? I have read about Vinculum system as it seems to be the most widely used.

It should be viable to implement it for handling numbers between the [4000,3999999] range. I have done a quick (and ugly :smile:) patch in order to filter the generated number (note that I have only implemented the arabic to roman conversion):

if (4000 <= $this->arabicNumeral && 3999999 >= $this->arabicNumeral) {
    return sprintf(
        '<span class="overline">%s</span>%s',
        str_replace('N', '', (new IntToRoman())->filter(intval(substr($this->arabicNumeral, 0, -3)))),
        str_replace('N', '', (new IntToRoman())->filter(intval(substr($this->arabicNumeral, -3))))
    );
} else {
    return (new IntToRoman())->filter($this->arabicNumeral);
}
wandersonwhcr commented 3 years ago

Sorry, I'm trying to update my package and only now I found this!

Thinking about it, we have UTF-8.

https://en.wikipedia.org/wiki/Numerals_in_Unicode#Roman_numerals

:)

wandersonwhcr commented 3 years ago

We can check this source, too.

https://www.unicode.org/charts/PDF/U2150.pdf

wandersonwhcr commented 3 years ago

If we will use Unicode definition, I think we must use only Archaic numerals.

And we must add an option to turn on this usage, like $this->automaton->useArchaic().