flyingsilverfin:
To save processing power (speed is vital, i have about 40 usec per loop)
This will shave a few to several machine instructions off your loop...
void loop( void )
{
while ( true )
{
// your code goes here
}
}
However, I need to do an if statement that looks like this:
if (unsignedLong-(int*byte) < long)
with the current setup. This wasn't working so i had to change the int to a long and then it worked...
This also would have solved the problem (names changed in an attempt to add clarity)...
if ( MyUnsignedLongVariable - ( (unsigned long) MyIntVariable * (unsigned long) MyByteVariable ) < MyLongVariable )
I'm wondering how the proc (alu?) does the math.
One byte at a time (it's an 8 bit processor).
For example if I want to add a long and a int, does it buffer the int with 0's?
No. The int value is "sign extended" to a long.
Or does it chop off the long?
No.
In this case, does the order I add in matter then?
Possibly. The operands are first extended to the "largest" datatype of each operand. For example, when adding an int to a long the int is first sign extended to a long and then the addition is performed.
References to material covering this would be fine... this is totally new ground for me so I didn't even know what to google
"type conversion" "sign extension" "type promotion" ...and, of course... "c++"