Q:

Conversion from code point to UTF-16 code unit surrogate pair

I am attempting to convert a Unicode character to a UTF-16 surrogate pair:
The character "Face with Medical Mask"  is code point U+1F637. 
In binary this is: 1 1111 0110 0011 0111. 
According to Wikipedia to encode this to UTF-16 I need to do the following:

0x10000 is subtracted from the code point 
11111011000110111 - 10000 = 011111011000100111
The high ten bits (in the range 0x000–0x3FF) are added to 0xD800 to give the first 16-bit code unit or high surrogate (W1)
0001111101  + 1101100000000000 = 01101100001111101 (D87D)
The low ten bits (also in the range 0x000–0x3FF) are added to 0xDC00 to give the second 16-bit code unit or low surrogate (W2), which will be in the range 0xDC00–0xDFFF. 
1000100111 + 1101110000000000 = 01101111000100111 (DE27)

So I have two code units D87D and DE27, but I know the correct result is:

console.log('\uD83D\uDE37')

What am I doing wrong? 

A:

You have:
0x10000 is subtracted from the code point 

11111011000110111 - 10000 = 011111011000100111

But 0x10000 is 1 0000 0000 0000 0000 in binary.   The correct arithmetic is therefore:
1 1111 0110 0011 0111 - 1 0000 0000 0000 0000 = 0 1111 0110 0011 0111

