Hello,
i have some variables say:
x=1.4
y=3.7
I wish to round off these values to :
x = 2 (after rounding off)
y = 4 (after rounding off)
I am stuck.
Please help. (7 Replies)
Hello,
I searched a lot on this Forum.
Please help me with the below problem.
I want to divide two numbers and the result should be the next nearest whole number.
E.G. Dividing 10.8/5 ideally gives 2.16. But the result should be 3 i.e. rounded off to the next whole number.
Any help will... (2 Replies)
Hi Guys,
I am generating a statistical report , below is the snippet of the code :
Now, $nSlices stands for the time duration,meaning,the statistics will be displayed for that particular time duration. Trouble is, for certain values of $totalTime (which is the end time - start time ), i... (9 Replies)
I had a person bring an interesting problem to me that appears to involve some sort of rounding inside awk. I've verified this with awk and nawk on Solaris as well as with gawk 3.1.5 on a Linux box.
The original code fragment he brought me was thus:
for (index=0; index < 1; index=index+.1)
... (4 Replies)
Hello Guys,
I'm very new on here and require some help matching up and printing some columns using awk.
I have two text files. The first file has Longitude data in column 1 (lon.txt) and the second one (node.txt) has again another Longitude data in column 1 (not exact as the first one) + in... (7 Replies)
Dear Experts,
I'm trying to find a way to round a number but in this way:
14367.577 ---> 14000
I used the following to round the number to the closer integer:
echo $var|awk '{print int($1+0.5)}'
and also:
xargs printf "%1.0f"
However, they don't work for my above... (9 Replies)
Hi all of you,
Would be great if you help me with how to round up to whole number from my input values like
2.99996,2.17890,3.00002,-2.3456,-2.7890
o/p should be like 3,2,3,-2,-3
thnks in adv!!!!
regards (3 Replies)
Heyas
Trying to calculate the total size of a file by reading its bitrate.
Code snippet:
fs_expected() { #
# Returns the expected filesize in bytes
#
pr_str() {
ff=$(cat $TMP.info)
d="${ff#*bitrate: }"
echo "${d%%,*}" | $AWK '{print $1}' | head -n 1
}
t_BYTERATE=$((... (9 Replies)
Hello Guys,
I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value
#!/bin/bash
#... (9 Replies)
Discussion started by: skatpally
9 Replies
LEARN ABOUT ULTRIX
fabs
floor(3m)floor(3m)Name
floor, ffloor, fabs, ceil, ceil, trunc, ftrunc, fmod, rint - floor, absolute value, ceiling, truncation, floating point remainder and
round-to-nearest functions
Syntax
#include <math.h>
double floor(x)
double x;
float ffloor(x)
float x;
double ceil(x)
double x;
float fceil(x)
float x;
double trunc(x)
double x;
float ftrunc(x)
float x;
double fabs(x)
double x;
double fmod (x, y)
double x, y;
double rint(x)
double x;
Description
The and routines return the largest integer which is not greater than x for double and float data types, respectively.
The and routines return the smallest integer which is not less than x for double and float data types, respectively.
The and routines return the integer (represented as a floating-point number) of x with the fractional bits truncated for double and float
data types respectively.
The routine returns the absolute value |x|.
The routine returns the floating point remainder of the division of x by y: zero if y is zero or if x/y would overflow; otherwise the num-
ber f with the same sign as x, such that x = iy + f for some integer i, and |f| < |y|.
The routine returns the integer (represented as a double precision number) nearest x in the direction of the prevailing rounding mode.
In the default rounding mode, to nearest, is the integer nearest x with the additional stipulation that if |rint(x)-x|=1/2 then is even.
Other rounding modes can make act like or or round towards zero.
Another way to obtain an integer near x is to declare (in C)
double x; int k; k = x;
The C compiler rounds x towards 0 to get the integer k. 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.
The routine is in libc.a rather than libm.a.
See Alsoabs(3), ieee(3m), math(3m)
RISC floor(3m)