[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] softfloat missing functions

From: Julian Seward
Subject: Re: [Qemu-devel] [PATCH] softfloat missing functions
Date: Mon, 19 Mar 2007 20:37:55 +0000
User-agent: KMail/1.9.5

> 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?


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 ?)
    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;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]