ParseInt and byte var type

I am declaring some variables this way
byte red;
byte green;
byte blue;

I am reading the data this way:

red = Serial.parseInt();
green = Serial.parseInt();
blue = Serial.parseInt();

It works fine but I was wondering if the parsing is changing my var types from byte to int. Size is crucial for the project I am working on and keeping variables as byte would save a lot of memory.

Thanks

but I was wondering if the parsing is changing my var types from byte to int.

No. Despite the name, parseInt() returns a long. Stupid not to name the function correctly, if you ask me. The value that is returned will overflow if it doesn't fit in the destination type. Your problem to deal with that.

Create a temporary long to hold the value from ParseInt. Check to make sure it fits into a byte before assigning it to your byte variable.

I used those functions here:
http://forum.arduino.cc/index.php?topic=147550.0

Easy to follow code.

   case 22:    //DPR DigitalPin Read # valid 2 - 13  Return 0, 1 for state or 2 for Error
            if (verbose) {Serial.print(F("Prompting for Digital Pin Number 2 - 13: ")); }
            DigPinNo = Serial.parseInt(); 
            if (DigPinNo <2 || DigPinNo > 13) {
              if (verbose) { Serial.print(DigPinNo);
                Serial.print(" Pin# Error"); break; }
                Serial << Err; break; }
            if (verbose) { Serial.print(DigPinNo); }
            if (verbose) {Serial.print(F(" Logic State = ")); }
            Serial << digitalRead(DigPinNo);
            if (verbose) {Serial.println(); }
            break;

Ray

Ok thanks guys- I'll leave it as is for now and if it bugs I'll just verify the var to make sure it doesn't overflow