Advertisement Jump to content
Sign in to follow this  

[.net] Single16 to float

This topic is 4886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to cast a DirectX.Single16 to a float? I'm trying to port some of the texture encoding code in the SDK's HDRFormats sample so I can encode HDR images as RGBE. I managed to find a 16-bit floating point value in DirectX.Single16 and I was like: yes! However, there does not appear to be a cast defined for (float)single16Val and indeed, its only members are the ordinary constants such as Epsilon. Their Single16 type seems to be useless! What can I do? Thanks in advance.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Have you tried somthing like:
float SingleCaster(Single16 input){
unsafe{return (float)((single*)&input)[0];}

What is the difference between System.Single and DirectX.Single16?

hope this helps.
turnpast (out of town)

Share this post

Link to post
Share on other sites
Thanks for the help.

But the 16-bit floats have a different number of mantissa and exponent bits so a straight cast wouldn't work.

I downloaded the August SDK the day before yesterday and that has a managed HDRFormats sample! So I wasted an hour the day before the day before yesterday porting the encoding code :(

Their encoding code doesn't use the Single16 at all - they use a 2D array of ColorValue with unsafe code.
But I'm waiting until the SDK can be installed - needs admin privileges. I had those on the old computer :(

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!