/* e_fmodf.c -- float version of e_fmod.c. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ #include #if defined(LIBM_SCCS) && !defined(lint) __RCSID("$NetBSD: e_fmodf.c,v 1.7 2002/05/26 22:01:49 wiz Exp $"); #endif /* * __ieee754_fmodf(x,y) * Return x mod y in exact arithmetic * Method: shift and subtract */ #include "math.h" #include "math_private.h" static const float one = 1.0, Zero[] = {0.0, -0.0,}; float __ieee754_fmodf(float x, float y) { int32_t n,hx,hy,hz,ix,iy,sx,i; GET_FLOAT_WORD(hx,x); GET_FLOAT_WORD(hy,y); sx = hx&0x80000000; /* sign of x */ hx ^=sx; /* |x| */ hy &= 0x7fffffff; /* |y| */ /* purge off exception values */ if(hy==0||(hx>=0x7f800000)|| /* y=0,or x not finite */ (hy>0x7f800000)) /* or y is NaN */ return (x*y)/(x*y); if(hx>31]; /* |x|=|y| return x*0*/ /* determine ix = ilogb(x) */ if(hx<0x00800000) { /* subnormal x */ for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1; } else ix = (hx>>23)-127; /* determine iy = ilogb(y) */ if(hy<0x00800000) { /* subnormal y */ for (iy = -126,i=(hy<<8); i>=0; i<<=1) iy -=1; } else iy = (hy>>23)-127; /* set up {hx,lx}, {hy,ly} and align y to x */ if(ix >= -126) hx = 0x00800000|(0x007fffff&hx); else { /* subnormal x, shift x to normal */ n = -126-ix; hx = hx<= -126) hy = 0x00800000|(0x007fffff&hy); else { /* subnormal y, shift y to normal */ n = -126-iy; hy = hy<>31]; hx = hz+hz; } } hz=hx-hy; if(hz>=0) {hx=hz;} /* convert back to floating value and restore the sign */ if(hx==0) /* return sign(x)*0 */ return Zero[(u_int32_t)sx>>31]; while(hx<0x00800000) { /* normalize x */ hx = hx+hx; iy -= 1; } if(iy>= -126) { /* normalize output */ hx = ((hx-0x00800000)|((iy+127)<<23)); SET_FLOAT_WORD(x,hx|sx); } else { /* subnormal output */ n = -126 - iy; hx >>= n; SET_FLOAT_WORD(x,hx|sx); x *= one; /* create necessary signal */ } return x; /* exact output */ } mmit message (Expand)Author 2019-09-01stat() was present in v1sevan 2017-02-03Remove comma after the last Nm entry.abhinav 2014-04-10Mention the word 'inode' next to st_ino so it's easier to find.wiz 2013-10-15Adjust needed includes for fchmodat/mkdirat/mkfifoat/mknodat/fstatatnjoly 2013-07-28Add fstatat(2) specific errors.njoly 2013-01-13Revert defective O_SEARCH implementation committed by manu@ along withdholland 2012-12-01Bump date. New sentence, new line. Wording/articles.wiz 2012-12-01Remove trailing whitespace.wiz 2012-11-18Add most system calls for POSIX extended API set, part 2, with test cases:manu 2012-01-04Fix a sentence, following a hint by Abhinav Upadhyay.wiz 2011-09-14There's no st_block field; it's st_blocks.apb 2011-02-21v-node -> vnodepooka 2010-11-25No file system I know of reports directory sizes that are multiples ofdholland 2010-06-04Fix .Xr; dirent(5) -> dirent(3).jruoho 2010-05-31Consistently use `.Brq Dv XXX' across syscalls man pages, for NAME_MAXnjoly 2010-05-18Split "file system" and fix a typo.wiz 2010-05-17Note that all stat-functions are standardized nowadays.jruoho 2010-05-17Try to describe the struct stat instead of copy-pasting it from the header.jruoho 2010-04-03Mention the history of stat(2) and fix the history of open(2).jruoho 2010-03-22Use .In for header files instead of .Ar Pa and variations.joerg 2010-02-12Fix typo.wiz 2009-05-13Sort errors. Avoid marking up punctuation.wiz 2009-03-11Fix markupjoerg 2007-06-10Note ZFS returning the number of entries instead of the size of the directory.christos 2005-12-26u_intN_t -> uintN_tperry 2005-06-14- Correct the fields in the stat structure. From PR/18255.peter 2004-05-13\- is a minus, not -.wiz 2003-08-07Move UCB-licensed code from 4-clause to 3-clause licence.agc 2003-04-16Usewiz 2003-01-18Merge the nathanw_sa branch.thorpej 2002-10-01New sentence, new line. From Robert Elz.wiz 2002-08-02stat(2) can return ENXIO.soren 2002-04-29Remove <sys/types.h> from synopsis, as per latest SUS/Posix specs.simonb 2002-02-08Generate <>& symbolically. I'm avoiding .../dist/... directories for now.ross 2002-02-03Add a reference to dir(5) per PR 14291fair