wenyan-lang / wenyan

文言文編程語言 A programming language for the ancient Chinese.
https://wy-lang.org/
MIT License
19.56k stars 1.1k forks source link

Suggestions for large/small number representation #231

Open statementreply opened 4 years ago

statementreply commented 4 years ago
  1. Follow more recent (say, Qing dynasty) conventions for small number representation. Specifically, 塵/埃/渺/漠 means 10^(-9/-10/-11/-12).
  2. Don't use Buddhism numbers (恆河沙, 剎那, etc.).
  3. Should we invent (?) a format similar to scientific notation? (e.g. 六又零二釐二毫進二十三 = 六千零二十二垓 = 6.022e+23, 六又六分二釐六毫退三十四 = 6.626e-34)
  4. Should we specify what to print for infinities and NaN?
melop commented 4 years ago

How about: https://zh.wikipedia.org/zh/%E8%8B%8F%E5%B7%9E%E7%A0%81%E5%AD%90

heangfat commented 4 years ago
  1. Positional Notation (or positional numeral system, 進位制或曰位值計數法) should be used, instead of the current reading notation. Chinese mathematics books have been using such system since the beginning.
  2. The digits used in positional notation is 筭籌 (counting rods). 蘇州碼子 is only a late variant of 筭籌 for common use, e.g., market price, (probably less than 1000 years). The symbol system of 蘇州碼子 is not as rigorous as 筭籌.
  3. Unicode put Counting Rods Numerals at 0x1D360 to 0x1D371 in the Supplementary Multilingual Plane 1 (except for 〇 in BMP), which has serious compatibility issue. The best way to realize it is making an OTF font which shows Arabic numerals as 筭籌, and alternates vertical and horizontal styles. This OTF font should be a Variable Font, with two axes: width and weight. I will implement this next year.

Here is an example taken from the book 測圓海鏡細草. 測圓海鏡

statementreply commented 4 years ago

Agreed that positional notation is a more practical choice for a programming language. It feels, however, less amusing :)

Perhaps we could parse numbers as positional system with optional power-of-10 number words. This would allow both (and more) formats:

Pros & Cons: