View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
bit_test a constant |
Posted: Fri Mar 09, 2012 2:17 am |
|
|
Hi,
Is there an easy way to bit_test a constant? the in-built bit_test function doesn't allow it. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Fri Mar 09, 2012 2:48 am |
|
|
Seems totally pointless. After all a constant, is constant, so the bit test is always going to return the same value.....
You can always just use a simple '&' test.
#define constant_bit_test(X,Y) (X&(1<<Y)!=0)
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Fri Mar 09, 2012 3:45 am |
|
|
thanks, they are "variable" constants in a separate file which are calibration constants to each micro but change for each device (separate file for each product)! As the compiler knows where in program space it has stored them I thought it might allow bit_wise access to them with an inbuilt function.
Your neat code looks great. Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
|