xref: /openbsd/lib/libm/man/fmod.3 (revision c1db31af)
1*c1db31afSschwarze.\"	$OpenBSD: fmod.3,v 1.13 2021/06/29 14:46:44 schwarze Exp $
2df930be7Sderaadt.\" Copyright (c) 1991 The Regents of the University of California.
3df930be7Sderaadt.\" All rights reserved.
4df930be7Sderaadt.\"
5df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
6df930be7Sderaadt.\" modification, are permitted provided that the following conditions
7df930be7Sderaadt.\" are met:
8df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
9df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
10df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
11df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
12df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
136580fee3Smillert.\" 3. Neither the name of the University nor the names of its contributors
14df930be7Sderaadt.\"    may be used to endorse or promote products derived from this software
15df930be7Sderaadt.\"    without specific prior written permission.
16df930be7Sderaadt.\"
17df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20df930be7Sderaadt.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27df930be7Sderaadt.\" SUCH DAMAGE.
28df930be7Sderaadt.\"
29df930be7Sderaadt.\"     from: @(#)fmod.3	5.1 (Berkeley) 5/2/91
30df930be7Sderaadt.\"
31*c1db31afSschwarze.Dd $Mdocdate: June 29 2021 $
32df930be7Sderaadt.Dt FMOD 3
33df930be7Sderaadt.Os
34df930be7Sderaadt.Sh NAME
358a2f5500Sderaadt.Nm fmod ,
367ac6a943Smartynas.Nm fmodf ,
377ac6a943Smartynas.Nm fmodl
388a2f5500Sderaadt.Nd floating-point remainder functions
39df930be7Sderaadt.Sh SYNOPSIS
4086f9d4cdStedu.In math.h
41df930be7Sderaadt.Ft double
42df930be7Sderaadt.Fn fmod "double x" "double y"
43df930be7Sderaadt.Ft float
44df930be7Sderaadt.Fn fmodf "float x" "float y"
457ac6a943Smartynas.Ft long double
467ac6a943Smartynas.Fn fmodl "long double x" "long double y"
47df930be7Sderaadt.Sh DESCRIPTION
48df930be7SderaadtThe
49df930be7Sderaadt.Fn fmod
50df930be7Sderaadtfunction computes the floating-point remainder of
51*c1db31afSschwarze.Fa x Ns / Ns Fa y .
52a856b3b0SjasonThe
53a856b3b0Sjason.Fn fmodf
54a856b3b0Sjasonfunction is a single precision version of
55a856b3b0Sjason.Fn fmod .
567ac6a943SmartynasThe
577ac6a943Smartynas.Fn fmodl
587ac6a943Smartynasfunction is an extended precision version of
597ac6a943Smartynas.Fn fmod .
60df930be7Sderaadt.Sh RETURN VALUES
61df930be7SderaadtThe
627ac6a943Smartynas.Fn fmod ,
63df930be7Sderaadt.Fn fmodf
647ac6a943Smartynasand
657ac6a943Smartynas.Fn fmodl
66df930be7Sderaadtfunctions return the value
67df930be7Sderaadt.Sm off
68df930be7Sderaadt.Fa x - Em i * Fa y ,
69df930be7Sderaadt.Sm on
70df930be7Sderaadtfor some integer
71df930be7Sderaadt.Em i
72df930be7Sderaadtsuch that, if
73df930be7Sderaadt.Fa y
74df930be7Sderaadtis non-zero, the result has the same sign as
75df930be7Sderaadt.Fa x
76df930be7Sderaadtand magnitude less than the magnitude of
77df930be7Sderaadt.Fa y .
78df930be7SderaadtIf
79df930be7Sderaadt.Fa y
80df930be7Sderaadtis zero, whether a domain error occurs or the
81df930be7Sderaadt.Fn fmod
82df930be7Sderaadtfunction returns zero is implementation-defined.
83df930be7Sderaadt.Sh SEE ALSO
840714f1f8Smartynas.Xr remainder 3
85df930be7Sderaadt.Sh STANDARDS
86df930be7SderaadtThe
87df930be7Sderaadt.Fn fmod
88df930be7Sderaadtfunction conforms to
89df930be7Sderaadt.St -ansiC .
9023fbb714Sschwarze.Sh HISTORY
9123fbb714SschwarzeAn
9223fbb714Sschwarze.Fn fmod
9323fbb714Sschwarzefunction first appeared in
9423fbb714Sschwarze.At v5 .
95