How does one obtain the complementary hexadecimal value for a given input ?
This could be a bit more generic, i.e. having an array of X possible values, how do you convert a random array like arr[x] –> arr[arr.length – arr.indexOf(x)].
Please ignore the syntax.
The following code snippet will find 16 complement of hexadecimal number:
Hope this will help you. Thank you.
Source:
First find the 15’s complement of the given input by subtracting it from the number FF… which is of the same length of the input. Then add 1 to it.