Live data from Hacker News

Commas in big numbers everywhere: An OpenType adventure

blog.janestreet.com

31–40 of 43 posts

Re: Commas in big numbers everywhere: An OpenType adventure

#31

AFAIK general style guides don't recommend using thousand separators in numbers below 10000, so "variable #1,234" is not quite good, it should've been simply "variable #1234". "Variable 12,345" would've probably been OK, but then there's another semantic issue: thousand separators are only used in numbers that mean quantities, not identifiers. Long numeric identifiers like phone number or SSN are usually separated di…

Also, this is locale specific. Here in Germany we use dots instead of commas for that.

Re: Commas in big numbers everywhere: An OpenType adventure

#32
post #30
post #22

Could this be an potential avenue for some sort of exploit? I had no idea that you could "execute" logic via fonts.

Uh oh. Are fonts now Turing-complete?

Yes: https://litherum.blogspot.com/2019/03/addition-font.html

Re: Commas in big numbers everywhere: An OpenType adventure

#33
post #6

Probably cool, but the website disables zooming in phones so I can't tell. I wish pages couldn't disable zooming -- that should be up to me. Does anyone know browsers that always allow zoomi (If any Jane Street blog folks read this, please fix your blog.)

I just rotated my phone to landscape.

Re: Commas in big numbers everywhere: An OpenType adventure

#34
post #31

AFAIK general style guides don't recommend using thousand separators in numbers below 10000, so "variable #1,234" is not quite good, it should've been simply "variable #1234". "Variable 12,345" would've probably been OK, but then there's another semantic issue: thousand separators are only used in numbers that mean quantities, not identifiers. Long numeric identifiers like phone number or SSN are usually separated di…

Also, this is locale specific. Here in Germany we use dots instead of commas for that.

Fortunately, OpenType fonts can have locale-specific behavior, so as long as your content is appropriately lang-tagged, that shouldn't be a problem.

(Though I still don't think doing this in the font is a good idea, in general.)

Re: Commas in big numbers everywhere: An OpenType adventure

#35
This is fantastic for command line output and whatever that doesn’t natively support digit grouping. I have no idea how people live without enabling it.

I turn it on my Windows calculator, and I’m also happy that now programming languages like JavaScript, Python and recently Go allows using underscores in numeric literals for doing this in code to make it more readable.

Re: Commas in big numbers everywhere: An OpenType adventure

#36
post #31

AFAIK general style guides don't recommend using thousand separators in numbers below 10000, so "variable #1,234" is not quite good, it should've been simply "variable #1234". "Variable 12,345" would've probably been OK, but then there's another semantic issue: thousand separators are only used in numbers that mean quantities, not identifiers. Long numeric identifiers like phone number or SSN are usually separated di…

Also, this is locale specific. Here in Germany we use dots instead of commas for that.

Not just Germany. Comma vs dot is just a big mess with some countries using both[1]. Even in Germany, which is decimal comma country, the dot is ubiquitous in science and technology publications. Best thing is to stick with dot and us neither comma nor dot as thousands separator but a thin, fixed space. This also what NIST recommends[2]:

> #16 Digit spacing

> The digits of numerical values having more than four digits on either side of the decimal marker are separated into groups of three using a thin, fixed space counting from both the left and right of the decimal marker. Commas are not used to separate digits into groups of three.

[1] https://en.wikipedia.org/wiki/Decimal_separator#/media/File:...

[2] https://physics.nist.gov/cuu/Units/checklist.html

Re: Commas in big numbers everywhere: An OpenType adventure

#37
post #34
post #31

Earlier quoted context omitted.

Also, this is locale specific. Here in Germany we use dots instead of commas for that.

Fortunately, OpenType fonts can have locale-specific behavior, so as long as your content is appropriately lang-tagged, that shouldn't be a problem. (Though I still don't think doing this in the font is a good idea, in general.)

So, one could have a font that, say, hides the flag of Taiwan in a Chinese locale? (Yes, there are multiple ‘Chinese’ locales:

  zh-CN Chinese (Simplified, PRC)
  zh-SG Chinese (Simplified, Singapore)
  zh-TW Chinese (Traditional, Taiwan)
  zh-HK Chinese (Traditional, Hong Kong S.A.R.)
  zh-MO Chinese (Traditional, Macao S.A.R.)

)

Re: Commas in big numbers everywhere: An OpenType adventure

#39
post #37
post #34

Earlier quoted context omitted.

Fortunately, OpenType fonts can have locale-specific behavior, so as long as your content is appropriately lang-tagged, that shouldn't be a problem. (Though I still don't think doing this in the font is a good idea, in general.)

So, one could have a font that, say, hides the flag of Taiwan in a Chinese locale? (Yes, there are multiple ‘Chinese’ locales: zh-CN Chinese (Simplified, PRC) zh-SG Chinese (Simplified, Singapore) zh-TW Chinese (Traditional, Taiwan) zh-HK Chinese (Traditional, Hong Kong S.A.R.) zh-MO Chinese (Traditional, Macao S.A.R.) )

Yes, but OpenType only supports 4 different Chinese locales (Chinese, Hong Kong SAR 'ZHH', Chinese Phonetic 'ZHP', Chinese Simplified 'ZHS', Chinese Traditional 'ZHT') https://docs.microsoft.com/en-us/typography/opentype/spec/la...

ZHP seems like it's unlikely to be used in the wild.

Re: Commas in big numbers everywhere: An OpenType adventure

#40
Presumable it handles text that already has a comma separator OK, since there isn't a continuous group of >3 digits in '1,234'.

I suppose the same is true of continental Europe's '1.234', though it would be very cool if it could be determined that the '.' was a thousand separator and modified to ','.

What happens though if the text is using '.' separator and ',' decimal, such as (roughly 123 and a half) '123,456789', is it going to determine there's a missing ',' between '6' & '7' (making it roughly 123 and a half million)?

Post reply on HN