Live data from Hacker News

So you think you know what a number is

chris.improbable.org

21–30 of 35 posts

Re: So you think you know what a number is

#22

Earlier quoted context omitted.

No worries, I'm sure the next version of Unicode will have a single glyph that provides a complete introduction to the topic.

We need to extend Unicode to account for quantum computing and qubits. It needs to evolve into Qunicode. Text with this feature baked in could be called Quneiform. It should be stored on light-reflecting crystals that are manufactured using kilns.

You should join the Unicode Consortium; I'm pretty sure you'd fit right in. :)

Re: So you think you know what a number is

#23

       int("一万三千二百六十九")
    Traceback (most recent call last):
       File "python", line 1, in 
    ValueError: invalid literal for int() with base 10: '一万三千二百六十九'
       int("一三二六九")
    Traceback (most recent call last):
      File "python", line 1, in 
    ValueError: invalid literal for int() with base 10: '一三二六九'
Well, that was disappointing. For the record, my site http://ichi.moe/ can handle both (and Arabic numerals too).

Re: So you think you know what a number is

#24
post #23

int("一万三千二百六十九") Traceback (most recent call last): File "python", line 1, in ValueError: invalid literal for int() with base 10: '一万三千二百六十九' int("一三二六九") Traceback (most recent call last): File "python", line 1, in ValueError: invalid literal for int() with base 10: '一三二六九' Well, that was disappointing. For the record, my site http://ichi.moe/ can handle both (and Arabic numerals too).

Speaking of Japanese, I previously wrote some pretty basic code for translating arabic to/from Japanese numerals:

https://github.com/navarr/JapaneseNumerals/blob/master/Japan...

Re: So you think you know what a number is

#26
post #20
post #18

Earlier quoted context omitted.

It works in Python 2, you just have to ensure that your string is unicode. I can't get it to work directly from the command line for some reason, but if you open an interactive Python session it works: Python 2.7.12 (default, Dec 14 2016, 13:32:53) [GCC 4.9.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print(int(u'۲۶۷۹')) 2679

Hmm, interesting. What's up with the terminal here? The shell is doing something to the text. $ python2.7 -c "print(int(u'۲۶۷۹'))" Traceback (most recent call last): File " ", line 1, in ValueError: invalid literal for int() with base 10: '\xdb\xb2\xdb\xb6\xdb\xb7\xdb\xb9' $ python2.7 Python 2.7.13 (default, Jan 03 2017, 17:41:54) [GCC] on linux2 Type "help", "copyright", "credits" or "license" for more information.…

DB B2, etc. are the UTF-8 encodings of U+06F2, etc. So Python is seeing mojibake: U+00DB (Û), U+00B2 (²), etc. which are not digits. Well, one of them kinda is, but it’s No (“Number, other”), not Nd (“Number, decimal digit”).

Re: So you think you know what a number is

#28
This applies in Java as well, for instance Integer.parseInt and Character.isDigit. Between Java and Python, you can get all sorts of numeric characters through a sizable percentage of web applications.

I haven't yet found a security vulnerability based in this, but I keep checking. :-)

Re: So you think you know what a number is

#29
post #23

int("一万三千二百六十九") Traceback (most recent call last): File "python", line 1, in ValueError: invalid literal for int() with base 10: '一万三千二百六十九' int("一三二六九") Traceback (most recent call last): File "python", line 1, in ValueError: invalid literal for int() with base 10: '一三二六九' Well, that was disappointing. For the record, my site http://ichi.moe/ can handle both (and Arabic numerals too).

That actually came up in the comments (http://chris.improbable.org/2014/8/25/adventures-in-unicode-...)

Apparently the Unicode consortium chose to exclude those characters because they weren't encoded in a contiguous sequence so they're defined as Numeric_Type=Digit rather than Numeric_Type=Decimal. They've apparently realized that this is not helpful but chose to apply the updated policy only to new ranges.

Re: So you think you know what a number is

#30
post #28

This applies in Java as well, for instance Integer.parseInt and Character.isDigit. Between Java and Python, you can get all sorts of numeric characters through a sizable percentage of web applications. I haven't yet found a security vulnerability based in this, but I keep checking. :-)

Also .Net: https://blogs.msdn.microsoft.com/oldnewthing/20040309-00/?p=...

… and, yes, that was definitely something I tried to find when I first noticed it.

Post reply on HN