0

I would like to get a dec value from a 20 bytes Hex-encoded string, and I coded as following:

//str is a 20 bytes hex string. For example, the variable str = (__NSCFString *) @"3EDB616369C275F09E03EC2E6BDF85F888851333"
unsigned int value = 0;
NNscanner *scanner = [NSScanner scannerWithString:str];
[scanner scanHexInt:&value];

But, however, I dont know why the line scanHexInt returns No and the variable value is not updated.

Tsubaki
  • 61
  • 5
  • 20 hex bytes are 160 bits, that number is far too large for a (64-bit) integer. – Martin R Jun 16 '20 at 07:57
  • And what's supposed to be the result? If you have a "20 bytes" value, how does it fit inside an unsigned int? Else https://stackoverflow.com/a/42200208/1801544 ? – Larme Jun 16 '20 at 08:00
  • Accordng to the apple document, Overflow is considered a valid hexadecimal integer representation.So, it should also return Yes even if this is overflow. – Tsubaki Jun 16 '20 at 15:17

0 Answers0