Normally people don’t change the MAC addresses of their interfaces which means that EUI-64 will change the 7 th bit from 0 to 1 most of the time. I have been searching for a method to convert a decimal MAC address into a hex one. When you change the MAC address this bit has to be set to 1. I want to convert a string of mac address into hex format. A “built in” MAC address will always have this bit set to 0. The 7 th bit represents the universal unique bit. This means that if it’s a 0 you need to make it a 1, and if it’s a 1 it has to become a 0. Here’s the conversion process step by step: take the mac address: for example 52:74:f2:b1:a8:7f. Traditional MAC addresses are 12-digit (6 bytes or 48 bits) hexadecimal numbers. To do this you have to convert the first two hexadecimal characters of the first byte to binary, lookup the 7 th bit and invert it. Convert a mac address between dot notation, bit-reversed, hexadecimal and more Paste MAC Address below. It doesn’t include the final step which is “inverting the 7 th” bit. So if my MAC address would be then this is what the interface ID will become:Ībove you see how we split the MAC address and put FFFE in the middle. convert the first octet from hexadecimal to binary: 52 -> 01010010.
Sounds complicated right? It's not, really. Another popular notation ix 0x.įor your example, there are 8 places. Hexadecimal: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14Ġ* indicates that it's base 16 (although this is the first time I've seen it). Decimal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Convert between unix timestamp and datetime formats. In hexadecimal, one placeholder can have values 0 through 15. String MacAddress'D6' Integer hex Integer.parseInt (MacAddress.substring (0,2), 16 ) byte byteArray (byte) hex. Since we're used to only 10 digits, we substitute letters for 11 through 15. The same idea applies to base 16 (e.g., hexadecimal - hex meaning 6 and decimal meaning 10 - 16). Has a '3' in the 1 place that's worth 3.Has a '2' in the 10 place that's worth 20.Has a '1' in the 100 place that's worth 100.
Each placeholder is worth whatever the base is set to.