code: function toPositiveHex(hexString){
    var mostSiginficativeHexAsInt = parseInt(hexString[0], 16);
    if (mostSiginficativeHexAsInt < 8){
      return hexString;
    }
  
    mostSiginficativeHexAsInt -= 8;
    return mostSiginficativeHexAsInt.toString() + hexString.substring(1);
  }
docs: a hexString is considered negative if it's most significant bit is 1 because serial numbers use ones' complement notation this RFC in section 4.1.2.2 requires serial numbers to be positive http://www.ietf.org/rfc/rfc5280.txt