1
0
mirror of https://gitlab.com/rnger/amath synced 2025-10-06 10:59:56 +00:00
Files
amath/doc/man/man3/floor.c.3
2017-01-24 22:03:15 +01:00

127 lines
2.8 KiB
Groff

.TH "lib/real/floor.c" 3 "Tue Jan 24 2017" "Version 1.6.2" "amath" \" -*- nroff -*-
.ad l
.nh
.SH NAME
lib/real/floor.c \-
.SH SYNOPSIS
.br
.PP
\fC#include 'prim\&.h'\fP
.br
.SS "Functions"
.in +1c
.ti -1c
.RI "double \fBfloor\fP (double x)"
.br
.RI "\fIMathematical floor function\&. \fP"
.in -1c
.SS "Variables"
.in +1c
.ti -1c
.RI "static const double \fBhuge\fP = 1\&.0e300"
.br
.in -1c
.SH "Function Documentation"
.PP
.SS "double floor (double x)"
.PP
Mathematical floor function\&.
.PP
\fBVersion:\fP
.RS 4
1\&.3
.RE
.PP
\fBDate:\fP
.RS 4
95/01/18
.RE
.PP
.PP
.nf
Return x rounded toward -inf to integral value
Method:
Bit twiddling\&.
Exception:
Inexact flag raised if x not equal to floor(x)\&.
.fi
.PP
.PP
\fBCopyright:\fP
.RS 4
Copyright (C) 1993 by Sun Microsystems, Inc\&. All rights reserved\&. Developed at SunSoft, a Sun Microsystems, Inc\&. business\&. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved\&.
.RE
.PP
.PP
Definition at line 66 of file floor\&.c\&.
.PP
References huge\&.
.PP
.nf
67 {
68 sword i0,i1,j0;
69 uword i,j;
70 EXTRACT_WORDS(i0,i1,x);
71 j0 = ((i0>>20)&0x7ff)-0x3ff;
72 if(j0<20) {
73 if(j0<0) { /* raise inexact if x != 0 */
74 if(huge+x>0\&.0) {/* return 0*sign(x) if |x|<1 */
75 if(i0>=0) {
76 i0=i1=0;
77 }
78 else if(((i0&0x7fffffff)|i1)!=0)
79 {
80 i0=0xbff00000;
81 i1=0;
82 }
83 }
84 } else {
85 i = (0x000fffff)>>j0;
86 if(((i0&i)|i1)==0) return x; /* x is integral */
87 if(huge+x>0\&.0) { /* raise inexact flag */
88 if(i0<0) i0 += (0x00100000)>>j0;
89 i0 &= (~i);
90 i1=0;
91 }
92 }
93 } else if (j0>51) {
94 if(j0==0x400) return x+x; /* inf or NaN */
95 else return x; /* x is integral */
96 } else {
97 i = ((uword)(0xffffffff))>>(j0-20);
98 if((i1&i)==0) return x; /* x is integral */
99 if(huge+x>0\&.0) { /* raise inexact flag */
100 if(i0<0) {
101 if(j0==20) i0+=1;
102 else {
103 j = i1+(1<<(52-j0));
104 if(j<(uword)i1) i0 +=1 ; /* got a carry */
105 i1=j;
106 }
107 }
108 i1 &= (~i);
109 }
110 }
111 INSERT_WORDS(x,i0,i1);
112 return x;
113 }
.fi
.SH "Variable Documentation"
.PP
.SS "const double huge = 1\&.0e300\fC [static]\fP"
.PP
Definition at line 46 of file floor\&.c\&.
.PP
Referenced by floor()\&.
.SH "Author"
.PP
Generated automatically by Doxygen for amath from the source code\&.