Pages

September 7, 2013

Word to NSInteger number conversion

Intermediate function that converts a Word into a NSInteger.
You need:
- http://objective-c-functions.blogspot.com/2013/08/hex-to-int-number-conversion.html

/** Convert a Word to an int.

 @param lowByte The low byte of the word.
 @param highByte The high byte of the word.
 @return Returns the integer value of the word.
 @see highLowBytesFromInteger:

 */
+ (NSInteger)intFromWordWithLowByte:(Byte)lowByte highByte:(Byte)highByte {

    NSString *startHexAddressHigh    = [NSString stringWithFormat:@"0x%X", highByte];
    NSString *startHexAddressLow    = [NSString stringWithFormat:@"0x%X", lowByte];

    NSInteger res = [LMFunctions intFromHex:startHexAddressHigh] * 16 * 16;
    res += [LMFunctions intFromHex:startHexAddressLow];

    return res;
}



Download the ready-for-use source file (.m) of Word to NSInteger number conversion

No comments:

Post a Comment