I'm floating integer to hex?
-
Alright...this is a small part of a problem I'm doing for C++ class..We have to store a floating integer T. T=1.5 . Now, we have to convert this stored value to hex...Kinda like this: float t; t = 1.5; std::hex << t << "\n"; Or whatever..You get the idea tho..store the value, and convert it to it's hex format. Have any suggestions?
-
Alright...this is a small part of a problem I'm doing for C++ class..We have to store a floating integer T. T=1.5 . Now, we have to convert this stored value to hex...Kinda like this: float t; t = 1.5; std::hex << t << "\n"; Or whatever..You get the idea tho..store the value, and convert it to it's hex format. Have any suggestions?
hello, i think you ar elooking for sprintf() function ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
-
Alright...this is a small part of a problem I'm doing for C++ class..We have to store a floating integer T. T=1.5 . Now, we have to convert this stored value to hex...Kinda like this: float t; t = 1.5; std::hex << t << "\n"; Or whatever..You get the idea tho..store the value, and convert it to it's hex format. Have any suggestions?
depends how do you want to convert it to hex ... you know usually only ints are converted to hexes ... floating part is not carried over. You could do printf( "%X", (int) t ); to print it in hex, but it will print only integer part. If you want to print its binary representation you could do printf( "%08X", *((long*) &t) );