# Roman numeral support in Number type

6 messages
Open this post in threaded view
|

## Roman numeral support in Number type

 This started as a joke, but after implementing it, I'd actually like to propose this as an addition and see what comes of it. I've added support for stringifying and parsing numbers to and from Roman numeral representation, using the usual Number functions:     var num = 5;     console.log(num.toString("r")); // logs "V"     console.log(parseInt("IX"));    // logs 9 https://github.com/penduin/romanumberI have two main questions: - Is this worth proposing?  It seems silly, but does deal with real numerical representations. - Is using "r" as a radix sane?  Would separate .toRomanString / .parseRoman be better? _______________________________________________ es-discuss mailing list [hidden email] https://mail.mozilla.org/listinfo/es-discuss
Open this post in threaded view
|

## Re: Roman numeral support in Number type

 Oh, wow. Sorry, but I don't see this happening any time soon. Here's just a few problems: - Roman numerals are hardly ever used. - `0` does not have a standard representation. - Fraction representation is possible, but relatively complicated. - The set of characters used for Roman numerals is non-standard. It varied over time and even geographically. - Often times, there are multiple representations for one and the same number - Fore more problems, see below. Contrary to popular belief, Roman numerals do **not** just consist of a bunch of (non-standard) letters that represent numeric values. In fact, there were different kinds of dots (uncia, sextans, …) that represented values in a duodecimal fraction system as well. Romans even started drawing lines around their numbers to indicate that the value of the represented numeral is multiplied or raised by some constant; look up "Vinculum". This was used to represent larger numbers. Another thing that was used for larger numbers was the "Apostrophus", which was an encasing system to indicate that the encased part is multiplied by a constant. How would you handle that, and how would you treat the optional contractions? ("C|Ɔ" → "ↀ", "|ƆƆ" → "ↁ", etc.) Suffice it to say that this doesn't fit into `parseInt`/`toString(n)` at all, as Roman numerals are a **nonpositional** numeral system. Therefore, it doesn't make sense to supply a radix. This kind of functionality is best kept in libraries. On Thursday, July 6, 2017 6:13:08 PM CEST Owen Swerkstrom wrote: > This started as a joke, but after implementing it, I'd actually like > to propose this as an addition and see what comes of it. > > I've added support for stringifying and parsing numbers to and from > Roman numeral representation, using the usual Number functions: >     var num = 5; >     console.log(num.toString("r")); // logs "V" >     console.log(parseInt("IX"));    // logs 9 > https://github.com/penduin/romanumber> > I have two main questions: > - Is this worth proposing?  It seems silly, but does deal with real > numerical representations. > - Is using "r" as a radix sane?  Would separate .toRomanString / > .parseRoman be better? > _______________________________________________ > es-discuss mailing list > [hidden email] > https://mail.mozilla.org/listinfo/es-discuss_______________________________________________ es-discuss mailing list [hidden email] https://mail.mozilla.org/listinfo/es-discuss signature.asc (849 bytes) Download Attachment
Open this post in threaded view
|

## Re: Roman numeral support in Number type

 Can we also support Maya numbers?They apparently do have a zero, the shell glyph which looks like .Newlines matter; each new line is multiplied by 20.Inexplicably, these glyphs do not yet seem to be in Unicode.BobOn Fri, Jul 7, 2017 at 10:11 AM, kdex wrote:Oh, wow. Sorry, but I don't see this happening any time soon. Here's just a few problems: - Roman numerals are hardly ever used. - `0` does not have a standard representation. - Fraction representation is possible, but relatively complicated. - The set of characters used for Roman numerals is non-standard. It varied over time and even geographically. - Often times, there are multiple representations for one and the same number - Fore more problems, see below. Contrary to popular belief, Roman numerals do **not** just consist of a bunch of (non-standard) letters that represent numeric values. In fact, there were different kinds of dots (uncia, sextans, …) that represented values in a duodecimal fraction system as well. Romans even started drawing lines around their numbers to indicate that the value of the represented numeral is multiplied or raised by some constant; look up "Vinculum". This was used to represent larger numbers. Another thing that was used for larger numbers was the "Apostrophus", which was an encasing system to indicate that the encased part is multiplied by a constant. How would you handle that, and how would you treat the optional contractions? ("C|Ɔ" → "ↀ", "|ƆƆ" → "ↁ", etc.) Suffice it to say that this doesn't fit into `parseInt`/`toString(n)` at all, as Roman numerals are a **nonpositional** numeral system. Therefore, it doesn't make sense to supply a radix. This kind of functionality is best kept in libraries. On Thursday, July 6, 2017 6:13:08 PM CEST Owen Swerkstrom wrote: > This started as a joke, but after implementing it, I'd actually like > to propose this as an addition and see what comes of it. > > I've added support for stringifying and parsing numbers to and from > Roman numeral representation, using the usual Number functions: >     var num = 5; >     console.log(num.toString("r")); // logs "V" >     console.log(parseInt("IX"));    // logs 9 > https://github.com/penduin/romanumber > > I have two main questions: > - Is this worth proposing?  It seems silly, but does deal with real > numerical representations. > - Is using "r" as a radix sane?  Would separate .toRomanString / > .parseRoman be better? _______________________________________________ es-discuss mailing list [hidden email] https://mail.mozilla.org/listinfo/es-discuss
Open this post in threaded view
|

## Re: Roman numeral support in Number type

 In reply to this post by Owen Swerkstrom Roman numerals are already supported by ECMAScript Internationalization API Specification:Try in Safari Browse:```new Intl.NumberFormat("it-u-nu-roman").format(10);```  _______________________________________________ es-discuss mailing list [hidden email] https://mail.mozilla.org/listinfo/es-discuss