   [HLSL] Can I put two 16bit number into one 32bit float?
  Well, as the thread title says: I would like to know if I can put two 16bit numbers into one 32 bit float. I C++, such things aren't very hard, but I don't now how to do it in HLSL...Edit: Oh, and I use the Shader model 4.0   
  Can you use half instead?What is it you are trying to acheive?   ;  I want to pack my variables a bit, so I need less MRTs.   ;  Shader model 4.0 has bit level instructions. You can do it just like you would in C++. There are instructions to convert between float and uint as a bit conversion as well.   ;  Why not just use a render target that has 2 16 bit components, like RabidDog suggested?   ;  Could you tell me an example? I only used makros like HIWORD in c++, and doing it by hand just confuses me :(   ;  This will be easier if you make your rendertarget format UINT, that way you can do the packing easily.  Packing to a FLOAT format is unnecessary effort.  Half and short types should be available for you to use.  You can also make use of intrinsics like asuint to reinterpret the bits for you.The bit shifting operators like >> and << will work on int and uint types.  You'll have to unpack the data, by extraction.  uint l = value & 0x0000FFFF; will provide you with the lower 16 bits, and uint h = value >> 16; will provide the higher 16 bits;Then convert l and h to a half (f16tof32() and f32tof16()) in order to do your math.  To repack you'll just do the reverse.Consider looking at the packing and unpacking functions from this thread for guidance.[Edited by - DieterVW on May 15, 2010 11:01:03 AM];  Thanks, that was what I needed. :)   ;  In HLSL you are not supposed to use any scalar type different than float and int.Int is purely for indexing needs.Even vertex function input structure is all float scalars,although the stream vertex declaration says its an for example unsigned char type. You can any time convert float to int in HLSL, so make vsinput all float, becouse it is float.And convert to int only when you need, it is a difficult operation. Pixel function output is a 4byte value, where 4 floats are normalized and converted to char type. Target format description describe the actual conversion. wheather 4 dimensional float vector to X8R8G8B8, thats each float to char, or D16 format, thats 1 dimensional float vector to small int.Also bare in mind you have clamped values to 0,1 in targets, becouse float needs to be 0-1 range for this byte rescaling conversion. At D16 format, If you want to write (-1,1) range floats to target ,rescale (fl+1.0)/2.0. Then , read two chars , likechar a;char b;read(&a,&b);int val=(unsigned char)a*(unsigned char)b;float value = val/sqr(256); // 256^2 range of two bytesfloat myscaled = (value-0.5)*2.0;;  @JohnnyCode thats true for the old versions of HLSL, but OP said he was using shader model 4 which allows float/int/uint as vertex members, render targets and variables.   