Conversion Fun

Something to do when you're bored.

1
2
signed long A = 1151803392;
float B;


Try converting A to B, so that B contains the same bits as A. You'll know when you've done it right. Some of you may even already recognize the above number, or you can guess what it is. This is a one-line process.

Now, after you have done that, find the most ridiculous way to do the same thing. Essentially create some Rube Goldberg code to convert it.
B = *(reinterpret_cast<float*>(&A));

memcpy(&B,&A,sizeof(B));

I don't recognize the number, nor do I feel like taking a Rube Goldberg approach =P But those were the first ways I thought of to do it.
Last edited on
Disch, print B after the conversion. Then you'll recognize it :D
I didn't use reinterpret_cast, instead I used this:
B = ((float*) &A)[0]
Last edited on
same difference. That's a C-style cast instead
Topic archived. No new replies allowed.