You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Sometimes you might define a constant with a calc like that to give a clue as to its origin. It could eg. be part of a set of like-calculated constants.
I think there is someone around here always harping that he considers verb-for-verb, function-for-function, statement-for-statement "ports" from one source language to another "stone losers."
I'll have to find that guy and send him an "Amen!" note with a link to this thread. I think a full text search on "stone loser" here ought to find him....
"<<" is the left shift operator. It is shifting the number 1 to the left 0 bits, which is equivalent to the number 1.
It is commonly used to create flags, numbers that can be combined together with | (bit or) and various operations can be applied to them, such as testing whether a flag is set, setting a flag, removing a flag, etc.
The reason that they can be combined together without interfering with each other is that each one is a power of two, and that is the reason for using 1 << x, because that yields powers of two:
They could easily have coded it explicitly with a comment like so:
#define SOMECONSTANT 16 ' Bit 4
Presumably, this constant is used to mask off bit 4 in a variable of bit flags. With PB's BIT statements/functions, I prefer to define constants like so (for this purpose):
%FlagDescription = 4 'Bit 4 of <some> flag variable
IF BIT( <flag variable>, %FlagDescription) THEN ...
>
I also have come to believe all 'c' compilers offer an '#OBFUSCATE ON|OFF' directive.. which defaults to ON.
It's an editor directive, actually. The compiler doesn't care.
The editor must be instructed at every step of the code construction.
One must consciously include obfuscation in each instruction.
But just trying to be clever is sufficient, so it's not as hard as it seems.
The world is strange and wonderful.*
I reserve the right to be horrifically wrong.
Please maintain a safe following distance.
*wonderful sold separately.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment