Ok Jack,
toggle quoted message
Show quoted text
I will concede that whitespace around the "==" would have been a good idea. And that the extra indent is an error. A work in progress, I did state it was "unproven". Guess I lose a grade point on style, but I'm happy with a passing grade of C. But far as I know, that code is correct and should work. And is short and concise, using only 32 bit integer math, and not much of it. I'd bet most code for SWR calculations will pull in a floating point library. I code for 1989 K&R ANSI C. And am fairly sure that older compilers had the same precedence rules for post decrement vs equality. Not that it matters, as all my ANSI C function declarations would fail on an old compiler anyway. I may have to dig out my 1978 K&R C book to check, just out of curiosity. I don't have a hex representation in there for 0, just for 0x30 which I for one easily recognize as an ascii '0'. I tend to write as compactly as possible. Most of my work is on a small chromebook, compact code lets me see as much of the problem as possible. If it's really tricky, I print what fits one sheet of paper and stick it in my back pocket for a few days.? Somehow that leaks through and up?into my brain, after a few days I understand my code. I get frustrated with code that has extra levels of indirection and is generally all spread out with lots of uninformative comments and boilerplating.? I don't get paid by the line.? Anyways, I guess it's fortunate that I write code for me and not for you. For both of us.? ?;-) Jerry On Sun, May 6, 2018 at 10:38 am, Jack Purdum wrote:
yet, which is easier to read? Also, if you just happened to use a pre-X3J11 compiler, the if() expression could be evaluated incorrectly since the post decrement operator has higher precedence than the test for equality. (True, the chances of that happening are pretty small, but still non-zero.) Finally, why use the hex representation for zero when '0' makes it easier to read? The indenting on the first example is misleading, since a quick glance makes it appear that the second call to the lcd object is controlled by the if expression, which it is not. Also, whitespace makes it easier to read expressions and cost nothing, so why not use it? You could also use the %= and /= operators, but that makes the code harder to read and has no impact on the generated code. Given a choice, I will always pick the form that is easier to read, especially when there's no performance hit. |