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
		
- 
				
				@spdhiraj99
 
 if you know the size you can just use a bitmask
 for 8 bit unsigned integers you can do
 x &= 0b01111111;
 
 for unsigned integers in general you can shift the number left and then shift it back right again
 x = (x<<1) >> 1;
- 
				
				 ivrat2578yMake a loop in which u test bits for example numbe 15 is 00001111 so u check 128 false then go lower 64 32 16 8 now 8 is set so u set it to 0 ivrat2578yMake a loop in which u test bits for example numbe 15 is 00001111 so u check 128 false then go lower 64 32 16 8 now 8 is set so u set it to 0
 If i got correctly what u mean
 
 Edit:
 Or u just shifting the number left til its same then right
- 
				
				Depending on how big the number is (bit size).. you can do this:
 
 (ex for 8 bit byte data type):
 
 Num = 11011011
 
 Num & 0xFE = 11011010
 
 If the number is 16 bit do this:
 Num & 0xFFFE
 
 Etc..
Related Rants
- 
						
							 xjose97x20Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop. xjose97x20Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
- 
						
							 elgringo41Student - Teacher renaming .c to .exe make the program executable ? Teacher - Yes A group of people stand up... elgringo41Student - Teacher renaming .c to .exe make the program executable ? Teacher - Yes A group of people stand up...
- 
						
							 Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ... Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...




Question
Is there a way to set MSB of a number to 0 ...?..
undefined
c++
c
problem solving
urgent