Could someone please tell me if i am correct in thinking if that Supported_PID20 has 00010000000000000000000000000000 in it and unsigned long i has (well think it should have if my code is correct) 00010000000000000000000000000000 in it the if statment will be executed?
Could someone please tell me if ... the if statment will be executed?
Can you modify that code to make it more obvious which block of code you're interested in having executed? There are three 'if' statements, two of which have an associated code block, and it's not obvious which of these five things you're talking about.
That is a VERY large number, much larger than can fit into a unsigned long. Is that decimal or binary representation?
This is the binary representation of the number.
Can you modify that code to make it more obvious which block of code you're interested in having executed? There are three 'if' statements, two of which have an associated code block, and it's not obvious which of these five things you're talking about.
The SupportedPID20 variable (decleared at the top of my code) will contain something like 11111111001111110001010111110111 binary (when running on a car) and lets say i variable will contain something like 00010000000000000000000000000000 binaray (if PID = 0x04). Am wanting to compare 1 bit so if bit 4 of SupportedPID20 is 1 and bit 4 of i is 1 will the if statment return true? Well thats what i want it to do anyway lol.
Pavilion1984:
PID is a byte that may contain anything from 0x01 to 0x20 and SupportedPID20 is a unsigned long type.
Save us all some pain.
Write a sketch that declares and initialises the variables you're using and then executes the code in question. Design the sketch to print something out when the right thing happens, and to print something different if the wrong thing happens. Tell us what happens when you run the code.