Old 11-08-2017, 12:34 PM   #1
Veto
Human being with feelings
 
Join Date: Aug 2010
Posts: 140
Default -----

-----

Last edited by Veto; 05-18-2018 at 08:37 AM.
Veto is offline   Reply With Quote
Old 11-10-2017, 03:24 PM   #2
casrya
Human being with feelings
 
Join Date: Dec 2013
Location: Melbourne, Australia
Posts: 96
Default

Not having a bitwise compliment operator is inconvenient but the code below seems to work ok although not necessarily better than what you already have but maybe conceptually clearer? Start with $xFF mask (11111111) or larger if you need more bits, then use XOR to clear the desired bit before ANDing with val to clear desired bit in variable. Didn't test for speed though.

@init
val=$xF0;
n=7; // MSB
val&=$xFF~(1<<n);
casrya is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.