> Do you mean to tell me that VS 6 is unaware of 64 bit integers? Or if it is,
> it can't
> convert between a 64 bit integer and a 64 bit floating point number (aka
> double)?
Been there / done that ;-)
When I read this, I remembered getting bit by this a long time ago on VC 6.
The following was the workaround:
/****************************************************************************
** ulonglong_to_double
** ulonglong uses an explicit conversion because VC6 does not provide
** an intrinsic conversion of unsigned __int64 to double; The following
** should even work across compilers that have the native conversion;
** It divides the unsigned word by two to guarantee a positive, signed
** result, converts the signed longlong to a double, then adds the
** shifted-out LS bit back in:
****************************************************************************/
inline double ulonglong_to_double( ulonglong value ) {
return( 2.0 * (double)(longlong)(value >> 1) + ((value & 1) ? 1.0 : 0.0) );
}
The types used were:
typedef __int64 longlong;
typedef unsigned __int64 ulonglong;
IIRC, conversion of an int64 to a double was OK, but not an unsigned
int64. Since unsigned values can be 2X bigger (no sign bit), the unsigned
value is cut in half, cast to int64, then cast to double. The shifted-out bit
is then brought back into the double result.
Eh, maybe not the most elegant, but IIRC it did the trick.
- Bill Prendergast
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/