I encountered a problem while adding long values Example
typedef unsigned short UINT16; UINT16* flash_dest_ptr; // this is equal to in hexa 0XFF910000 UINT16 data_length ; // hex = 0x000002AA & dec = 682 //now when I add UINT16 *memory_loc_ver = flash_dest_ptr + data_length ; dbug_printf( DBUG_ERROR | DBUG_NAVD, " ADD hex =0x%08X\n\r",memory_loc_ver );
Actual O / p = 0xFF910554
// shouldn't o/p be FF9102AA ?
Pointer arithmetic therefore
UINT16 *memory_loc_ver = flash_dest_ptr + data_length ;
advances flash_dest_ptr by data_length * sizeof (UINT16) bytes.
flash_dest_ptr
data_length * sizeof (UINT16)
Typically, sizeof (UINT16) will be 2, and
sizeof (UINT16)
2 * 0x2AA = 0x554
When you add integers to the pointer value, you actually move the pointer as much as it would take to move the data_length UINT16 in memory, not data_length bytes.
data_length
UINT16
Source: https://habr.com/ru/post/1480161/More articles:Using sqlalchemy to execute sql DRASTICALLY slows down runtime - pythonSolutions for TicTacToe - c ++Auto layout prevents me from changing view center - iosWhen to use stored procedures and triggers against the applicative layer - phpHow can I access the name of the current route in the meteor when using the meteorite router? - meteorHow do I use the preview date in preview mode to display date-specific content in Sitecore? - sitecorehow to generate a list of (unique) words from a text file in ubuntu? - ubuntuMultidimensional search by combining geospatial indices - algorithmHow to get Spring to create AOP proxies for my beans - javaNSTextField text and background color with / without focus - cocoaAll Articles