十进制为十六进制在C的Int64 [英] Decimal to hex for int64 in c
本文介绍了十进制为十六进制在C的Int64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这个code不起作用?
的#include<&iostream的GT;
#包括LT&;&cstdio GT;
诠释主(){
的printf(%X,1327644190303473294);
}
我收到O / P 5f264e8e
但预计O / P是 126cbd5b5f264e8e
如下面的PHP脚本给
< PHP
回声dechex(1327644190303473294);
?>
解决方案
便携的方式做,这是
的#include< inttypes.h>
和做的:
的#include<&stdio.h中GT;
#包括LT&;&inttypes.h GT; //为PRIX64宏(从stdint.h INT64_C宏)INT主要(无效)
{
的printf(的值%PRIX64\\ n,INT64_C(1327644190303473294));
返回0;
}
Why this code does not work ?
#include <iostream>
#include <cstdio>
int main() {
printf("%X", 1327644190303473294);
}
I am getting o/p 5f264e8e
but expected o/p is 126cbd5b5f264e8e
as given by below php script
<?php
echo dechex(1327644190303473294);
?>
解决方案
The portable way to do this is to
#include <inttypes.h>
And to do:
#include <stdio.h>
#include <inttypes.h> // for PRIX64 macro (and INT64_C macro from stdint.h)
int main(void)
{
printf("The value is %"PRIX64"\n", INT64_C(1327644190303473294));
return 0;
}
这篇关于十进制为十六进制在C的Int64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文