isEven is a performant, hand-compiled evenness checker for any 32 bit integer. A single file import that does one job and one job only!
4 billion if statements (2023)
111–120 of 183 posts
Re: 4 billion if statements (2023)
#112Earlier quoted context omitted.
> This is time efficient* but rather wasteful of space. You're saying that the blog's solution is time efficient. Which it is not. Your solution may be O(1) but it is also not efficient. As I'm sure you are aware. I can tell you a practical solution which is also O(1) and takes up maybe 2 or 3 instructions of program code and no extra memory at all. `x & 1` or `x % 2 != 0` This blog post was taking a joke and running…
You need to read their entire comment as a joke.
lol
Re: 4 billion if statements (2023)
#113This is time efficient* but rather wasteful of space. The best way to save space is to use a Bloom Filter. If we capture all the even numbers, that would sadly only give us "Definitely not Even" or "Maybe Even". But for just the cost of doubling our space, we can use two Bloom filters! So we can construct one bloom filter capturing even numbers, and another bloom filter capturing odd numbers. Now we have "Definitely…
How is this time efficient at all? It takes upwards of 40 seconds to compute on large 32bit values. It's a joke post with some interesting bits and details.
Re: 4 billion if statements (2023)
#114Earlier quoted context omitted.
But then, even numbers will have the worst possible performance.
Good point. Have two programs - one checking every even number and returning odd of not even. And then have a program checking every odd number and returning even if not. Then, a simple program to dispatch to either program randomly, so you end up in the long term with good performance for each.
Re: 4 billion if statements (2023)
#115> As a side note, the program is amazingly performant. For small numbers the results are instantaneous and for the large number close to the 2^32 limit the result is still returned in around 10 seconds. Amazing!
Re: 4 billion if statements (2023)
#116Re: 4 billion if statements (2023)
#117Re: 4 billion if statements (2023)
#118Earlier quoted context omitted.
You need to read their entire comment as a joke.
I guess I should have been more clear that I was just pointing out the obvious in case some confused reader missed the joke. lol
Re: 4 billion if statements (2023)
#119This is time efficient* but rather wasteful of space. The best way to save space is to use a Bloom Filter. If we capture all the even numbers, that would sadly only give us "Definitely not Even" or "Maybe Even". But for just the cost of doubling our space, we can use two Bloom filters! So we can construct one bloom filter capturing even numbers, and another bloom filter capturing odd numbers. Now we have "Definitely…
How is this time efficient at all? It takes upwards of 40 seconds to compute on large 32bit values. It's a joke post with some interesting bits and details.