[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: int/float binary conversion
From: |
Ulrich Eckhardt |
Subject: |
Re: int/float binary conversion |
Date: |
Wed, 14 Sep 2005 19:41:10 +0200 |
User-agent: |
KNode/0.8.2 |
Lars Christian Jensen wrote:
> float f1 = 4.5;
> int i = *((int*)&f1);
> float f2 = *((float*)&i);
>
> printf("f1 = %f, i = 0x%08x, f2 = %f\n", f1, i, f2);
You are using stupid, brute force casts to convert between totally
unrelated objects and expect anything useful?
Sorry, but what exactly is your problem? If you wanted to demonstrate that
it is possible to write C++ programs that don't behave consistently (i.e.
show different implementations of 'undefined behaviour'), fine, but we all
knew that already.
Uli
--
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/