T
Tim Rentsch
glen herrmannsfeldt said:Tim Rentsch said:[considering n = n * 10 + (*s - '0') vs n = *s-'0' + n*10 ]
It was conscious, because I had to consider whether to add the
parentheses. In my usual work environment, they wouldn't
matter, so I would very likely leave them out. In this
newsgroup, little omissions like that can get you attacked
without mercy. So I did think about whether to put in the
parentheses, and that caused me to carefully consider the whole
expression.Sorry, I wasn't clear. What I was (and am) curious about is
the choice between putting the multiplication term first or
second. Were both of those among the alternatives you
considered? (And, unimportant side issue: how about 10*n
instead of n*10?)
Usual math notation for polynomials puts the higher powers on
the left, and the coefficient to the left of the variable.
[snip elaboration and unrelated]
I don't find this idea very compelling either as explanation or as
argument. That is one common notation, but certainly not the only
one. Also it's true that the expression in question happens to be
a polynomial, but I expect that observation would not occur to
most software developers who write code to do such things. At
best it suggests there may be an unconscious habit of writing the
multiplication first, and probably there is some truth in that,
but that's a far cry from making an aesthetic choice. It seems
much more likely that people tend to write the multiplication
first simply because the first textbook or example they read of
how to do base conversion used 'n*10 + digit', or something
similar, in its code.