The test is bin:unpack-unsigned-integer(xs:base64Binary(xs:hexBinary('ffffffffffffffff')),0,8,'most-significant-first') and the expected result is -1. We are getting the result 18 446 744 073 709 551 615 which seems correct to me.