怎样输出整数的补码与原码
怎样输出整数的补码与原码??
char*_itoa(intvalue,char*string,intradix);
value-----要转换的整形值 string-----转换后的字符串 radix------表示基数(2, 8, 10, 16)等进制基数 本函数与char * itoa(int, char *, int);相同 还有其他类似的转换函数 char *_i64toa(__int64value,char*string,intradix); char*_ui64toa(unsigned_int64value,char*string,intradix); wchar_t*_itow(intvalue,wchar_t*string,intradix); wchar_t*_i64tow(__int64value,wchar_t*string,intradix); wchar_t*_ui64tow(unsigned __int64value,wchar_t*string,intradix); 后三个为转换宽字符 eg: #include <stdlib.h> #include <stdio.h> void main( void ) { char buffer[20]; int i = 3445; long l = -344115L; unsigned long ul = 1234567890UL; _itoa( i, buffer, 10 ); printf( "String of integer %d (radix 10): %s\n", i, buffer ); _itoa( i, buffer, 16 ); printf( "String of integer %d (radix 16): 0x%s\n", i, buffer ); _itoa( i, buffer, 2 ); printf( "String of integer %d (radix 2): %s\n", i, buffer ); _ltoa( l, buffer, 16 ); printf( "String of long int %ld (radix 16): 0x%s\n", l, buffer ); _ultoa( ul, buffer, 16 ); printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul, buffer ); } output: String of integer 3445 (radix 10): 3445 String of integer 3445 (radix 16): 0xd75 String of integer 3445 (radix 2): 110101110101 String of long int -344115 (radix 16): 0xfffabfcd String of unsigned long 1234567890 (radix 16): 0x499602d2 说明:例题来自MSDN 2002