On Wed, Jun 18, 2008 at 6:59 PM, Gabriel Sechan <[EMAIL PROTECTED]> wrote:
>
> Does anyone have or know where to find the algorithm for floor(double)?  I 
> have to implement this on a platform without a working implementation and I'd 
> rather not have to come up with it myself-  working with mantissas and 
> exponents hurts my brain.

You don't mention the software and hardware environment you are working in.

I break open my copy of _The Standard C Library_, P.J.Plauger,
Prentice Hall 1992.

Turning to page 141 I see one-line definitions of double (ceil)
(double x) and double (floor) (double x).
They both depend on an internal function _Dint which "tests and clears
all fraction bits less than a threshold value".  Note "The code for
clearing fraction bits is a bit tricky."

Turning over to page 142, I see the C code for function _Dint.  It
takes up the whole page.  About 50 lines.  Possibly this is on line
somewhere, but I found it easier to open the book.

    carl
-- 
 carl lowenstein marine physical lab u.c. san diego
 [EMAIL PROTECTED]

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to