__int_as_float(0xC0000000) is equal to -2, why?

Type cast function, Guide 1.1 P41
__int_as_float(0xC0000000) is equal to -2
__float_as_int(1.0f) is equal to 0x3f800000
What is principle of the transformation?

By casting to/from integer, it is giving you bit-level access to the single precision float representation:

http://en.wikipedia.org/wiki/Single_precision

It comes in very handy if you have a struct with 3 floats and 1 int. You can store it this way on the CPU, but if you read it from a texture on the GPU you can only read a float4. Using __float_as_int, you can tell the compiler that the 4th float is really an integer.

What seibert said.

0xC0000000 in binary form is 1 10000000 00000000000000000000000
s = -1
e = 1
m = 1.0
-1 * 2^1 * 1.0 = -2.0

For the binary form of 1.0f we need the following values:
s = 1
e = 0
m = 1.0
This translates into 0 01111111 00000000000000000000000, which is the same as 0x3f800000

Thanks a lot!