Converting numbers randomly puts negative values

Im putting a 32 bit file in an array and the number is not as expected and when I multiply an unsigned char I end up with a negative number!!!!

ino file const unsigned char Serialno[]={9,72,69,15,81}; volatile uint32_t SerialNoInt; void setup() {

// put your setup code here, to run once: Serial.begin(9600); Serial.println(Serialno[0]*100000000); Serial.println(Serialno[1]*1000000); Serial.println(Serialno[2]*10000); Serial.println(Serialno[3]*100); Serial.println(Serialno[4]); SerialNoInt= Serialno[0]*100000000+Serialno[1]*1000000+Serialno[2]*10000+Serialno[3]*100+Serialno[4]; Serial.println(SerialNoInt); } void loop() { // put your main code here, to run repeatedly:

}

Result 900000000 72000000 -30896 1500 81 971970685

Force the compiler to use unsigned math.

Serial.println(Serialno[0]*100000000UL);

Not just unsigned but force the long int calculation, so the L at the end of the numbers is super important Serial.println(Serialno[0]*100000000U[b][color=red]L[/color][/b]);

If you don’t force the use of a long value, the compiler defaults to an int and will perform the computation using 2 bytes (on a 8 bit arduino) instead of 4 which will drive the behavior You see