> Note that float64_to_uint64 functions are not correct, as they won't
> return results between INT64_MAX and UINT64_MAX. Hope someone may know
> the proper solution for this.

How about this?

J

uint64_t float64_to_uint64 (float64 a STATUS_PARAM)
{
    uint64_t res;
    int64_t v;

    if (isinf(a) || isnan(a)) {
       return special value (  maybe 1<<63 ?)
    }
    else
    if (a < 0.0 || a > (float64)UINT64_MAX) {
       return out-of-range value, whatever that is
    } else {

       a += (float64) INT64_MIN;  // move a downwards 
       v = llrint(a);             // convert
       v -= INT64_MIN;            // move v back up

       return v;
    }
}


_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to