Is there such a thing as the address of a boolean variable?
boolean x;
address of x = &x
Can that be done?
Is there such a thing as the address of a boolean variable?
boolean x;
address of x = &x
Can that be done?
What happened when you tried it ?
Why do you want to do it ?
Lots of errors, but don't know if I'm doing it right. Hence the question. If it is not legal (ie. can't be done) then any and all other questions are pointless.
Works for me. What did you try?
void setup() {
bool flag;
bool *addressOfFlag = &flag;
Serial.begin(115200);
delay(1000);
*addressOfFlag = true;
printBool(flag);
*addressOfFlag = false;
printBool(flag);
}
void loop() {}
void printBool(bool b) {
Serial.print("Boolean Variable = ");
if (b) {
Serial.println("true");
} else {
Serial.println("false");
}
}
Yes, you can take the address of a Boolean variable.
If you need more guidance, post your code and the error messages you got.
You are perfectly alright! The idea is not new; the root goes back to 8051 architecture where there are bit addressable RAM locations and each bit location has it own unique address. The 8051 also supports instructions for performing single bit data read/write operations with these bit locations.
The following codes work fine in the UNO Platform:
void setup()
{
Serial.begin(9600);
bool x = HIGH; // or make it LOW
bool *p;
p = (bool*) &x;
bool m = *p;
Serial.println(m, BIN); //shows 1 or 0
}
void loop()
{
}
GolamMostafa:
You are perfectly alright! The idea is not new; the root goes back to 8051 architecture where there are bit addressable RAM locations and each bit location has it own unique address. The 8051 also supports instructions for performing single bit data read/write operations with these bit locations.The following codes work fine in the UNO Platform:
[
Booleans are not single bit variables.
Booleans are true or false, not HIGH or LOW.
We were/are the generations of Boolean Processors where processing took/takes place on boolean variables not on boolean logic?
GolamMostafa:
We were/are the generations of Boolean Processors where processing took/takes place on boolean variables not on boolean logic?
Wuh?
adwsystems:
Is there such a thing as the address of a boolean variable?
I think this question stems from the misconception that a Boolean occupies 1 bit. It does not. It occupies 1 byte and this
is for the purpose of having an address.
@adwsystems, do not cross-post. Thread locked.
This is the problem @adwsystems is trying to solve...
http://forum.arduino.cc/index.php?topic=539351.msg3689189#msg3689189