home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------
- * filename - modf.cas
- *
- * function(s)
- * modf - splits into mantissa and exponent
- *-----------------------------------------------------------------------*/
-
- /*
- * C/C++ Run Time Library - Version 5.0
- *
- * Copyright (c) 1987, 1992 by Borland International
- * All Rights Reserved.
- *
- */
-
-
- #pragma inline
- #include <asmrules.h>
-
- #include <_math.h>
- #include <math.h>
-
-
- /*--------------------------------------------------------------------------*
-
- Name modf - splits into mantissa and exponent
-
- Usage double modf(double value, double *wholeP);
-
- Prototype in math.h
-
- Description modf breaks the double value into two parts: the integer
- and the fraction. It stores the integer in wholeP and
- returns the fraction.
-
- Return value modf returns the fractional part of value.
-
- *---------------------------------------------------------------------------*/
- #pragma warn -rvl
-
- double _FARFUNC modf( double value, double *wholeP )
- {
- asm FLD DOUBLE (value)
-
- asm mov ax, value [6]
- asm shl ax, 1
- asm cmp ax, 0FFE0h /* infinite exponent ? */
- asm jnb mdf_infinite
-
- asm FLD st(0) /* duplicate ST */
-
- asm mov ch, 0Ch /* chop towards zero */
- __round();
-
- asm LES_ bx, wholeP
- asm FST DOUBLE (ES_ [bx]) /* *wholeP = chop (value) */
-
- asm FSUBP st(1), st /* fraction = value - chop(value) */
-
- mdf_end:
- return;
-
- mdf_infinite: /* infinity == rounded (infinity) */
- asm LES_ bx, wholeP
- asm FSTP DOUBLE (ES_ [bx])
- asm FLDZ /* zero = infinity - infinity */
- asm jmp short mdf_end
- }
- #pragma warn .rvl
-