From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTOgK-0003iP-4Y for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:42:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTOgH-0003gZ-A6 for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:42:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTOgH-0003gS-5K for qemu-devel@nongnu.org; Mon, 19 Mar 2007 15:42:13 -0500 Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HTOem-0000nT-3n for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:40:40 -0400 From: Julian Seward Subject: Re: [Qemu-devel] [PATCH] softfloat missing functions Date: Mon, 19 Mar 2007 20:37:55 +0000 References: <1174291106.24702.9.camel@rapid> In-Reply-To: <1174291106.24702.9.camel@rapid> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703192037.55757.jseward@acm.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "J. Mayer" > 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; } }