FLOOR(3M)FLOOR(3M)NAME
fabs, floor, ceil, rint - absolute value, floor, ceiling, and round-to-nearest functions
SYNOPSIS
#include <math.h>
double floor(x)
double x;
double ceil(x)
double x;
double fabs(x)
double x;
double rint(x)
double x;
DESCRIPTION
Fabs returns the absolute value |x|.
Floor returns the largest integer no greater than x.
Ceil returns the smallest integer no less than x.
Rint returns the integer (represented as a double precision number) nearest x in the direction of the prevailing rounding mode.
NOTES
On a VAX, rint(x) is equivalent to adding half to the magnitude and then rounding towards zero.
In the default rounding mode, to nearest, on a machine that conforms to IEEE 754, rint(x) is the integer nearest x with the additional
stipulation that if |rint(x)-x|=1/2 then rint(x) is even. Other rounding modes can make rint act like floor, or like ceil, or round
towards zero.
Another way to obtain an integer near x is to declare (in C)
double x; int k; k = x;
Most C compilers round x towards 0 to get the integer k, but some do otherwise. If in doubt, use floor, ceil, or rint first, whichever you
intend. Also note that, if x is larger than k can accommodate, the value of k and the presence or absence of an integer overflow are hard
to predict.
SEE ALSO abs(3), ieee(3M), math(3M)4th Berkeley Distribution May 12, 1986 FLOOR(3M)
Check Out this Related Man Page
FLOOR(3M)FLOOR(3M)NAME
fabs, floor, ceil, rint - absolute value, floor, ceiling, and round-to-nearest functions
SYNOPSIS
#include <math.h>
double floor(x)
double x;
double ceil(x)
double x;
double fabs(x)
double x;
double rint(x)
double x;
DESCRIPTION
Fabs returns the absolute value |x|.
Floor returns the largest integer no greater than x.
Ceil returns the smallest integer no less than x.
Rint returns the integer (represented as a double precision number) nearest x in the direction of the prevailing rounding mode.
NOTES
On a VAX, rint(x) is equivalent to adding half to the magnitude and then rounding towards zero.
In the default rounding mode, to nearest, on a machine that conforms to IEEE 754, rint(x) is the integer nearest x with the additional
stipulation that if |rint(x)-x|=1/2 then rint(x) is even. Other rounding modes can make rint act like floor, or like ceil, or round
towards zero.
Another way to obtain an integer near x is to declare (in C)
double x; int k; k = x;
Most C compilers round x towards 0 to get the integer k, but some do otherwise. If in doubt, use floor, ceil, or rint first, whichever you
intend. Also note that, if x is larger than k can accommodate, the value of k and the presence or absence of an integer overflow are hard
to predict.
SEE ALSO abs(3), ieee(3M), math(3M)4th Berkeley Distribution May 12, 1986 FLOOR(3M)
function date_diff
{
integer _dt1=$(date_to_num ${1:?})
integer _dt2=$(date_to_num ${2:?})
integer _ndt=0
if ]
then
((_ndt=_dt2-_dt1))
fi
print -- $_ndt
}
What does double dash '--' indicate ?
Can anyone please answer this (2 Replies)
Hello Experts,
Is there any inbuild FLOOR function to do FLOOR func in mathmetics in awk script like in FlOOR Func in C.
Ex:- floor(2.9) = 2
floor(2.1) = 2
floor(2.0) = 2
floor(-2.0) = 2
floor(-2.1) = -3
floor(-2.9) =... (1 Reply)
Hey guys I would like to know how to find nearest numbers based on second column in 1st column some thing like this
Input
col1 col2
10 20
30 40
48 64
55 71
70 90
output
col1 col2 col3
10 20 30
30 40 48
48 64 70
55 71
70 90 (1 Reply)
Hi,
I'm trying to find the nearest match between two columns of numbers, e.g.
1,1
10,8
30,50
20,100
and the search could be e.g. 20,20
returning 10,8 - i.e. 20-10 = 10 and 20-8 = 12 totalling 22, and hence being the nearest match.
any ideas?
thanks a lot, (1 Reply)
I've been going through a java tutorial, and ran across some strangeness in this small example...
class SqrRoot {
public static void main(String args) {
double num,sroot,rerr,resquare;
for(num = 1.0; num < 100.0; num++) {
sroot = Math.sqrt(num);
... (1 Reply)
i'm a newbie here, i need help with a shell script.
for a given number, if it is greater than ten round to the nearest 10
same for 100, if it is greater than 100 round to the nearest 100, and same for 1000.
i'm confused how to start this...
its supposed to look like this
input ... (11 Replies)
Hi all,
Does anyone know how to simulate a ceiling or floor function in UNIX? OS is Solaris. I tried the suggestion from an old forum but it is giving me error as below:
server01/tmp$: echo "7.2" | awk '{printf("%d\n",$0+=$0<0?0:0.999)}'
awk: syntax error near line 1
awk: illegal... (3 Replies)
Hi,
I have the following code in which i am trying to find ceil of 10th & 11th fields. For finding ceil i have a function in the awk statement. When i test it for some values say on command line it gives correct response(say $10=0 & $11=750). But when the same value occurs in a file having more 3... (5 Replies)
Hello,
I am using bash shell on Linux OS, May i please know why is it rounding for big numbers but not for others, is there a workaround to print it as it is with out round off?
printf '%'\''.2f\n' 9999999999999999999.99
10,000,000,000,000,000,000.00
printf '%'\''.2f\n' 99999999999999.99... (1 Reply)
Hello,
My round and floor functions in C program behaves weird. Can someone help resolve the issue..
fprintf( fp, "ROUND TEST VARIABLE 11686776.000000 %d\n", round(11686776.000000));
fprintf( fp, "ROUND TEST VARIABLE 1168677.000000 %d\n", round(1168677.000000));
fprintf( fp, "FLOOR... (3 Replies)
Hi, can anyone provide more details to why an audio file's duration is seen as 10 seconds on unix and 9 seconds on windows
Read about windows MFT rounding down to nearest seconds, is there any article on unix rounding up?
thanks in advance (1 Reply)