Am I missing something?
First int uses 16 bits, 22 and 57 only need 8 bits each, so byte or char or uint8_t will do.
Second, what is displayed as 22 is stored in binary as b00000000 00010110 (0x0016). When you shift it left 16 bits you get
b00010110 00000000 00000000(0x160000), which is 1441792 decimal.
Then you have 57 decimal, which is b00000000 00111001 (0x39)
OR the two and you get b00010110 00000000 00111001 (0x160039), which is 1441849 decimal.
- Remember that numbers are stored in binary
- You've shifted left 16 bits when you only needed to shift 8
- Shifting won't work anyway for decimal numbers, well it will but not the way you are expecting
If you look at the DS3231 data sheet you will see it doesn't store the time in simple binary, it uses binary coded decimal. So, for example 22:57 is stored as:
Minutes register (0x01) 0x57 (b0101 0111), which if you treat as binary would convert to 87 decimal
Hours register (0x02) 0x22 (b0010 0010), which if you treat as binary would convert to 34 decimal
I'm guessing you are using a library for the DS3231, which will hide the binary coded decimal from you.