Sign in to follow this  

[.net] Single16 to float

This topic is 4488 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

This topic is 4488 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this