⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fmod.c

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 C
字号:
/* fmod.c - fmod math routine *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01g,05feb99,dgp  document errno values01f,05feb93,jdi  doc changes based on kdl review.01e,02dec92,jdi  doc tweaks.01d,28oct92,jdi  documentation cleanup.01c,20sep92,smb  documentation additions01b,30jul92,kdl  changed _d_type() calls to fpTypeGet().01a,08jul92,smb  documentation.*//*DESCRIPTIONSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "math.h"#include "stddef.h"#include "errno.h"#include "private/mathP.h"/********************************************************************************* fmod - compute the remainder of x/y (ANSI)** This routine returns the remainder of <x>/<y> with the sign of <x>,* in double precision.* * INCLUDE FILES: math.h** RETURNS: The value <x> - <i> * <y>, for some integer <i>.  If <y> is* non-zero, the result has the same sign as <x> and magnitude less than the* magnitude of <y>.  If <y> is zero, fmod() returns zero.** ERRNO: EDOM** SEE ALSO: mathALib*/double fmod    (    double x,	/* numerator   */    double y	/* denominator */    )    {    double	t;    short	negative = 0;    int		errx = fpTypeGet (x, NULL);	/* determine number type */    int		erry = fpTypeGet (y, NULL);	/* determine number type */    if (errx == NAN || erry == NAN || errx == INF || erry == ZERO)        {        errno = EDOM;				/* Domain error */        return ((errx == NAN) ? (x) : ((erry == NAN) ? (y) : (0)));        }        if (errx == ZERO || erry == INF)	return (x);		    /* make x and y absolute */    if (y < 0.0)	y = -y;    if (x < 0.0)	{	x = -x;	negative = 1;	}    /* loop substracting y from x until a value less than y remains */    for (t = x; t > y; t -= y)        ;    return ((t == y) ? (0.0) : ((negative) ? (-t) : (t)));    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -