On Thu, Aug 11, 2011 at 4:07 PM, Michael Mc Donnell michael@mcdonnell.dk wrote:
On Thu, Aug 11, 2011 at 3:01 PM, Matteo Bruni matteo.mystral@gmail.com wrote:
2011/8/11 Michael Mc Donnell michael@mcdonnell.dk:
- dst_ptr[0] = src->x < 0.0f ? (SHORT)ceilf(src->x * SHRT_MAX + 0.5f) :(SHORT)floorf(src->x * SHRT_MAX + 0.5f);
You can use roundf() instead. Actually, notice that maybe what you actually need for correct rounding is rintf() (which essentially matches what D3DXFloat32To16Array does). You should probably test this (even on your own, not necessarily adding those to the testsuite, I'd say).
Ok I'll look into that. I also noticed that I had a bug in the UBYTE4 conversion. I'll modify the tests to catch those cases.
Is it ok to use roundf and rintf? They're both C99 functions [1].