Jack Purdum
No, I understand what the code does. My question is why write it in such a confusing way. As my subsequent post states, there's nothing to be gained from this way of writing the code, other than making it take longer to read it and determine what it does.
I realize it's legal C, but if you tried compiling it on some earlier (pre-X3J11) compilers, it would not have worked correctly. Writing it using the simpler syntax would have worked correctly on any C compiler. It would also help to know the data types for the variables used in your code and what values are used to initialized them. It makes it hard to judge the algorithm. For example, what if someone sets div to a negative number? Finally, given that itoa() and dtosf() are debugged and prewritten-written using hand-tweaked assembler, why reinvent the wheel? Jack, W8TEE
On Sunday, May 6, 2018, 1:03:26 PM EDT, Jerry Gaffke via Groups.Io <jgaffke@...> wrote:
This line ? ??if (d--==r)? ?lcd.print('.'); is legal C. We could make it more verbose if that was too confusing: if (d==r)? { ? lcd.print('.'); } d = d -1; That function pnum()? prints a number as either floating point with a specified decimal point position or as an integer without a decimal point if we specify a decimal point position of 0. The value r is kept constant within the function, says how many digits after the decimal point to be printed. The value d keeps track of how many digits we have yet to print. It's my substitute for the itoa() routine used in the default code. Jerry On Sun, May 6, 2018 at 08:32 am, Jack Purdum wrote:
|