chanchungfat Posted September 20, 2009 Share Posted September 20, 2009 For some reason, I need to set and reset each bit of a variable and then transmit it. After a lot trial, I find that the setbit, clearbit function don't work. Here is my test code, it is very simple: Global m m = 0b00000011 clearbit(m, 1) I use a variable box to observe the m, with or without line 3 (clearbit(m,1)), the box always shows "3". Can you help me? Anything I overlooked? Regards, chanchungfat Link to comment Share on other sites More sharing options...
AzeoTech Posted September 20, 2009 Share Posted September 20, 2009 Yes. Clearbit is like pretty much any other function. It doesn't edit the variable passed in, but rather returns the result. So you want: m = clearbit(m,1) Think of it like Sin(). You wouldn't write just sin(m) and expect m to change to the sign of itself. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.