lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Jul 12, 2018 at 8:00 AM, Dirk Laurie <> wrote:
2018-07-12 13:38 GMT+02:00 Frédéric van der Plancke <>:
> On 10/07/2018 23:56, Gregg Reynolds wrote:
> On Tue, Jul 10, 2018, 4:44 PM Gregg Reynolds <> wrote:
>>  (e.g. numbers in ltr scripts).
> Correction: numbers in rtl scripts. Unicode says that numbers in e.g. Arabic are ltr. This is complete BS, but it is also a fact on the ground that cannot be fixed. Extra credit: estimate the cost of this very fundamental mistake.
> I'm not sure it's a mistake, it may be a well-though design compromise.
> In arabic, the numbers are written in the same orientation as we do in european languages, because of a double inversion: from right to left, they first write the unit, then the 10s, then the 100s... the end result being that in both writing systems, the units go to the right and the heavier digits go to the left.

I once was an examiner in a mathematics competition in which some of
the competitors wrote in Arabic. The mathematical formulae were
written as Western mathematicians write them, and so were the numbers.
When I made a remark to this effect to my Algerian colleague, he
responded by asking me to add two ten-digit numbers that he had
written down. Naturally I started at the unit as I was taught in
primary school, and he stopped me right there. "Why do you start the
addition at the right, if you do everthing else from left to right?" I
replied "Because that's how the algorithm works." He then said: "But
it's our algorithm.  An Arab mathematician invented it, and it starts
at the right because we write numbers that way."

He was right, you know!

Actually, he was wrong on several counts. Al-Khwarizmi was a Persian, not an Arab, even though he wrote in Arabic. His work introducing decimal positioning is lost, all we have is a Latin translation, so we don't really know what his original algorithm was. In any case, it's not about the algorithm, it's about the positioning; you can use whatever algorithm you want so long as you evaluate the positions correctly.

Traditionally, in Arabic numbers were read Least Significant Digit first - RTL. This is still acceptable today - I have heard radio announcers do it.

Where Unicode went off the rails is in claiming RTL languages are somehow inherently bidirectional. This is patently false, and biased: it assumes that Most Significant Digit first is "normal". If the shoe were on the other foot, it would be the LTR languages that are bidirectional. But in fact all languages (writing systems) are unidirectional with respect to numbers.

The reason Unicode numbers are MSD-first is because the legacy encodings were, and they were that way because they were invented in the days of data processing with punch cards. Doing  it that way allowed the use of the math routines that were already available for MSD-first numbers.