N_CODE can differ from N_VALUE because N_VALUE holds only the bottom nibble of N_CODE.
This line uses N_CODE, but it should use N_VALUE.
N_CODE
N_VALUE