linux - How to print hexadecimal double in C? -
i have number in hexadecimal: ffffffffffff and need save it, used double double a=0xffffffffffff; but need print , don't know how to. each time use %f , %d , %x , doesn't print value of it; need print ffffffffffff . code: int main() { double a=0xffffffffffff; printf("%x\n",a); printf("%d\n",a); printf("%x\n",a); printf("%f\n",a); return 0; } the true value %f ; returns decimal value of hexadecimal — returns this: ffffffe0 -32 ffffffe0 281474976710655.000000 with need change hexadecimal string, compare it, because have ffffffffffff in string , need compare both. if can't printf it, neither sprintf work. that's integer, , long one. don't use double store such value, that's floating-point. just use: unsigned long long temp = 0xffffffffffffull; you have 12 hexadecimal digits, number needs @ least 12 * 4 = 48 bits. platforms should have unsigned long long ...