How set the baud rate for serial communication in ATmega32u4
An unsigned char should always be 8-bits or a single byte.  Forget that it is a 'character' but rather just a number data type that is the same size as our registers. Since we are passing in a number that could possibly be as large 12 bits, our function is accepting a data type that is large enough for baud (unsigned int). This could either be 32 or 16-bits (does not matter in this case) depending on our architecture.

For this architecture, our UBRRHn and UBRRLn registers are 1 byte each. We do not have a single register that is large enough to take that 12-bit value so we have two 8-bit registers, and as you mentioned, we split up that 12-bit number into each.  UBRRHn takes the upper 4 bits, while UBRRLn takes the lower 8.

We shift the unsigned int 8 positions down to get those upper 4 bits.  Let's take a trivial example with all '1' bits:

baud = 4095;
UBRRHn = (unsigned char)(baud&gt;&gt;8);
// our shift: 0b0000111111111111 &gt;&gt; 8 == 0b0000000000001111
// after cast &amp; assignment, UBRRHn == 0b00001111
UBRRLn = (unsigned char)baud;
// after cast &amp; assignment, UBRRLn == 0b11111111


Our cast to unsigned char will take the lower 8-bits since unsigned char is an 8-bit data type.

I don't have time to go over the other sample code but it could be that he's using some macro or something at compile time to split it up for him.  You could dig deeper and find where UBBR1 is defined.  If you don't trust it, don't use it.  Do what you know to be true for your hardware configuration first and test it.