开发者

How does this address (0x00000400) = 1024

Im working in C++ and I have a #define VAL 0x00000400. when I set a variable equal to the define: int value = VAL; when I run through the debugger is shows the variable value = 1024. could someone explain how that turns into 1024? Maybe some links to memory address info, #define info, or something rele开发者_运维知识库vant.


0x00000400 is base 16 for 1024. Your debugger is showing you the integer value in base 10.


"0x400" is hexadecimal, or base 16. 0x400 expressed as decimal (base 10), is 1024.

By the way, you can use google to do base conversions. Search for "0x400 in decimal" and google will give you the answer.


0x00000400 is 400 base 16, which is 1024 base 10.


1024 in decimal = 400 in hex.


0x400 is a hexadecimal number (indicated by the 0x prefix.) It is another way of representing the decimal number 1024.


Additionally, the conversion from 0x400 (base 16) to base 10 is:

4*16^2 + 0*16^1 + 0*16^0
4*16^2 + 0 + 0
4*256
1024


well, I haven't seen your code, but 400h = 1024 decimal and you specify integer ' int value = VAL ' compiler just does not display any notice/warning, it does the cast for you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜