user42225: In Arduino Mega 2560 R3, properly selecting the Serial Monitor bauds, this code works with #define R 38400, but for some reason, not with #define R 19200 (?), 

#define R 38400
int rate=R;
HardwareSerial* hwSerial[]={&Serial,&Serial1,&Serial2,&Serial3};
void setup() {
    for (int i=0;i<=3;i++){
        hwSerial[i]->begin(rate);
        while (!hwSerial[i]);
    } 
    hwSerial[0]->print("Hello World"); 
}

void loop() {
}

Both speeds should be not problematic for Arduino, what is happening?
It seems the int rate R; is problematic when changing speeds (??).

user37622: Answer is simple. You assign 38400 to a variable of type int. The signed range of integer values that can be stored in 16 bits is −32,768 through 32,767;

42225: <p>In Arduino Mega 2560 R3, properly selecting the Serial Monitor bauds, this code works with <code>#define R 38400</code>, but for some reason, not with <code>#define R 19200</code> (?), 
</p>

<pre class="lang-cpp prettyprint-override"><code>#define R 38400
int rate=R;
HardwareSerial* hwSerial[]={&amp;Serial,&amp;Serial1,&amp;Serial2,&amp;Serial3};
void setup() {
    for (int i=0;i&lt;=3;i++){
        hwSerial[i]-&gt;begin(rate);
        while (!hwSerial[i]);
    } 
    hwSerial[0]-&gt;print("Hello World"); 
}

void loop() {
}
</code></pre>

<p>Both speeds should be not problematic for Arduino, what is happening?</p>

<p>It seems the <code>int rate R;</code> is problematic when changing speeds (??).</p>
 37622: <p>Answer is simple. You assign 38400 to a variable of type int. The signed range of integer values that can be stored in 16 bits is −32,768 through 32,767;</p>
