terraego
-
Posts
2 -
Joined
-
Last visited
Never -
Donations
0.00 GBP
Content Type
Profiles
Bug Tracker
Wiki
Release Notes
Forums
Downloads
Blogs
Events
Posts posted by terraego
-
-
Hey, this is my first post!
i was reading through some mangos source code and i'm really interested in how this emulator works. im quite new to c++ but i cant help but notice that people dont use bitwise operators. like so:
if (a&b) { action }
instead of
if (a&&b) { action }
now bitwise operators are faster. if 'a' is false it automaticly stops processing and return 0, it doesnt check the other variable. so i was interested and did some tests. this is what came out:
********************************** bitwise [00]: 2235 nanoseconds result: false bitwise [10]: 1676 nanoseconds result: false bitwise [01]: 2235 nanoseconds result: false bitwise [11]: 1676 nanoseconds result: true ********************************** non bitwise [00]: 2793 nanoseconds result: false non bitwise [10]: 1955 nanoseconds result: false non bitwise [01]: 1955 nanoseconds result: false non bitwise [11]: 1677 nanoseconds result: true **********************************
as you can see, using bitwise operators is at least 10% faster then not using bitwise operators. for the testing i used:
if (a && b) { result = true; } else { result = false; }
the using of bitwise operators seems faster when using while, will this help you guys in any way?
Bitwise operators
in OldC / C++
Posted
ah okay! i always programmed in java and just recently started c/c++ it works a bit different in java so i thought maybe it would be faster in c/c++ too