Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4681385yint x = 2;
If(x % 2 == 0)
//Even!!!
Else
// yea not so even ๐
Nothing complicated about that part. -
C0D4681385y@irene i found a comparison and unless your using it a billion times I doubt the difference will matter at the end of the time.
http://mziccard.me/2015/05/... -
@C0D4 you might not care, that's why we have electron, but some applications need any bit of optimization, especially on thousands of ops a second and for faster processing if run on a client machine.
Edit: then there's also resource restricted development environments like embed, where u really don't want to be wasting another division on what could be a simple bitmask. -
C0D4681385y@JoshBent ๐electron, just add x100 to all results -> and that's just getting it started for the first iteration.
Like I said, unless your running through thousands of ops/second the performance is mostly not going to kill your product either way.
There's a difference between not caring about performance and throwing electron at the problem ๐ -
C0D4681385y@JoshBent not really, that's a bit like dropping an A-Bomb (electron) on a fly to kill it, you and I both wouldn't do it - there's more efficient ways.
Having a 1.5second difference (on avg) for... 10 billion iterations if I saw that right... won't be the worst thing in the world, keep reading, unless your running this thing 24/7 on an endless supply of data.
Then yea let's take the care to get more data through the hole or just spin up another process. -
dmonkey23275y@C0D4 Honestly,
bool isOdd = x & 1
Is much nicer to see according to me...
Ps: I always get confused with even and odd in english -
dmonkey23275y@irene what do you mean? Why is it redundant? In my small experience I enjoy that Platon-like thinking
-
dmonkey23275y@irene Mine was a joke on the parallelism between Plato's philosophy and OOP paradigm. Idea-matter ~ Class-object
-
@C0D4 really everyone should be using their language's standard function for checking this. It will almost certainly be implemented with AND op, because mod gets expanded to many instructions whereas AND is 1:1. You can also do (num & 1) == 0 which is just as short as mod, but only works with integers.
-
@dmonkey does this work in all languages though? Boolean is usually a byte or larger on most
-
dmonkey23275y@beegC0de to be honest I don't know. I used it only with C, python and Java. I can suppose it works everywhere, but never tested decently. Oh and MIPS asm too, but on 32 bit arch, where everything is 32 bit long
Related Rants
1 - when I actually got the point of OOP
2 - When I got that I could check if a number was odd or even by doing & 1
3 - (in the future) when I will understand lifetimes in rust.
rant
wk169