fixed S value check with correct big-endian comparison