Let me count the ways



  • The camera system that I am using that have mentioned in previous WTFs is programmed via a spreadsheet metaphor using vendor supplied domain specific functions. All in all its not a bad system, but it only implements floating point numbers with a 7 digit integral value (and I don't know how many bits of resolution there are after the decimal point). We of course want to count events with 8 digit integer accuracy, so we are forced to break the counting into two parts and manually carry the rollover in the least significant digits to the most significant digits and happily count away. At least that is how I would have done it. My colleague split the 8 digit counting into a single digit least significant part and a 7 digit most significant part. He uses the event we are counting to trigger integral counting from 0 to 9 in the least significant digit and then rolls back over to 0 on the tenth event. But this isn't carried over to the most significant digits, no instead he uses the original trigger and increments the most significant digits by 0.1 each time.

    This scheme still wasn't working properly for some reason (and on this death march project I have to much to do let alone debug his work), so I suggested that he should break the digits up into groups of 4, not knowing how he was actually doing things under the hood. Well he took my words literally and created a counter that went from 0-9999 for the least significant digits. And for the most significant digits? Well he continued on the same scheme except this time he incremented the most significant digits by 0.0001 every time. And for some reason he did not quite understand why he wasn't getting accurate counting in the most significant digits.

    The scary thing is that my part of the job has run crazy late because of being forced into a re-write by a badly oversold job. I'm done with my stuff now, but due to my slippage my colleague has had an extra 3 weeks just to get these counters working properly - and still isn't done



  • How the fuck does one program if one can't even count?



  • @dhromed said:

    How the fuck does one program if one can't even count?

    Simple. One just doesn't use old-school BASIC.



  • @dhromed said:

    How the fuck does one program if one can't even count?

    That is a key question, and I am still shaking my head over it. I know he can use the pointy clicky stuff to "write" the part of the code where the camera isolates segments of the image and compares them to expected values, but I am suspecting that it is cargo cult programming. It seems that he has no concept of what a floating point number is, and has no idea of how to structure code (what I have seen of his work can be best described as a complete mess) . On the other hand my degree is in Electrical Engineering and as part of my course I had to build a 4bit CPU from physical 7400 series gates so I am very familiar with counters that roll over and manually having to carry bits to the next counter.



  • I could understand that he have difficulty understanding all of that (for me, mathematic is not in what I had the best result) but still, normally, when you don't what you are doing and just do shit, you ask for help so someone can explain it to you.



  • @TheMugs said:

    when you don't what you are doing and just do shit, you ask for help so someone can explain it to you.

    I think he has been asking for help - he did finally ask me last week - but I am not sure he can explain the problem clearly enough in order to get a solution to the real problem. For example asking "I tried incrementing by 0.0001 and it is not accurate" vs "How do I build a two part counter that rolls over from the first part to the second part"

    As for asking me, I did reply with a proof of concept that worked with two single digit counters (so you could count 00-99) and said that it could easily be expanded to two 4 digit counters (the actual problem) but he couldn't follow my solution. So I had to rework it for him.



  • The "bug" is simple. Specifically, 0.1 cannot be represented exactly in binary. So, 10*0.1 is not precisely 1, and the errors compound.

    But, it is a wonderful approach - just change the update slightly. Something like OLD = X; X = X + 0.11; IF INT(X) <> INT(OLD) THEN X = INT(X), should work, and keep a delightful level of WTF in the code. After all, think of the joy you can pass on to future maintainers!



  •  @ratboy667 said:

    The "bug" is simple. Specifically, 0.1 cannot be represented exactly in binary. So, 10*0.1 is not precisely 1, and the errors compound.

    But, it is a wonderful approach - just change the update slightly. Something like OLD = X; X = X + 0.11; IF INT(X) <> INT(OLD) THEN X = INT(X), should work, and keep a delightful level of WTF in the code. After all, think of the joy you can pass on to future maintainers!

    Ugh. Your statement (since it is correct) makes me realize I hadn't realized the state of computer science (probably a misnomer anyway) is so bad that folks are no longer requried to understand the differences between fixed point and floating point operations as well as basic binary representations.



  • @OzPeter said:

    he couldn't follow my solution.
     

    He can't do the job.



  • @dhromed said:

    @OzPeter said:

    he couldn't follow my solution.
     

    He can't do the job.

    After I sent him my proof of concept I made comments that he would want me to expand it out for him. He proved me right!


Log in to reply