1673
posted ago by Tech_guru ago by Tech_guru +1673 / -0

Someone wrote code to fudge the numbers and it wasn’t by accident, you don’t see this type of error on things like this

Comments (45)
sorted by:
You're viewing a single comment thread. View all comments, or full comment thread.
6
Wahzuhbee 6 points ago +6 / -0

Can you imagine any amateur coder using a floating point decimal to store vote tallies? That shit is the biggest red flag off the bat.

3
Asun 3 points ago +3 / -0

There is no reason to use float for counting votes. You only need to do addition or in rare case subtraction.
Unless, there's a weighting operation where you multiply with fraction. Hmmmm... Even then you can easily recast the result back to integer. These people are really dumb.

2
TheMoreYouKnowOkay 2 points ago +2 / -0

Raw amounts should always be in integers, and unsigned if your language supports it.

Yet I see programs all the time where they just use a float or double for these sorts of things. Programming is not being taught correctly in many places.

Here's an example of a major program with this error, libcurl: https://curl.se/libcurl/c/CURLINFO_SIZE_DOWNLOAD.html

"Pass a pointer to a double to receive the total amount of bytes that were downloaded."

Since it's an amount, double is definitely wrong.

It continues: "CURLINFO_SIZE_DOWNLOAD_T is a newer replacement that returns a more sensible variable type."

That function is described here: https://curl.se/libcurl/c/CURLINFO_SIZE_DOWNLOAD_T.html

"Pass a pointer to a curl_off_t to receive the total amount of bytes that were downloaded."

A curl_off_t is an unsigned integer. Which is a more sensible variable type.

Voting machine source code should be 100% open and auditable and ensured it's not written by amateur programmers who cannot even get basic data types right.

However, over here it's not a bug, it's a feature. These voting machines allow for tabulating "weighted votes" in which case the result is using a floating point decimal.

See this video explaining that this feature is included in voting machines and some of the algorithms backing it up: https://www.youtube.com/watch?v=Ztu5Y5obWPk