I’m looking for an efficient way of testing eights. What happens is I need to check if a value is eights and discard it.
The numbers I need to check for are:
8.8888, 88.888, 888.88, 8888.8, 88888.00 // 5 digits 88.8888, 888.888, 8888.88, 88888.8, 888888.00 // 6 digits 888.8888, 8888.888, 88888.88, 888888.8, 8888888.00 // 7 digits 8888.8888, 88888.888, 888888.88, 8888888.8, 88888888.00 // 8 digits
However, these are actually represented in integer form. Which is the number multiplied by 10000.
8.8888 is represented as an int64 with the value
888888.00 is represented as
There are quite a few values here to check. My simple approach was to just compare each one directly from a table. But then I thought perhaps I should maybe do something more efficient like masking and comparing each digit. But my crude approach did not work. It seems cumbersome and potentially a bit slow to convert to a string and compare eights that way. This code will run on an embedded system which checks these values many times over so I do need it to be reasonably performant. Note that I won’t have less than 5 digits represented or more than 8.