Below is the snippet of the code that i have written. The damn sprintf is not working. No matter what number i enter, it is entering ceil and not floor.Any reasons why ?
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 Experts,
I have a command that gives me the output as below
root@ckpgpay11core> cat sara | awk '{ sum += $1} ; END { print sum }' | awk {'print $1/90'}
8.88889
how do i remove the decimal spaces so that the figure will round itself to 9?
Thanks. (3 Replies)
Hi,
I am trying to find if there is a way to convert regular decimal values to Paced decimal values. I tried to find a c program but I could get a Packed converted to regular decimal not the other way round.
If not unix please let me know if any other progrimming language I can use to do... (2 Replies)
Is there a way I can round time in perl to the nearest five minutes?
For example if I have log giving the following time stamps
23,52,30 it would rounded up to 23,55,00
and
23,50,01 would be rounded to 23,50,00 (3 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)
I have a number, which I want to convert into the nearest floating number upto two places after the decimal point.
E.g.
1.2346 will become 1.23
but
1.2356 will become 1.24 .
Similarly
0.009 will be 0.01
and
0.001 will be 0.00 or 0.0 (not 0, wnat to keep the decimal... (1 Reply)
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)
Discussion started by: sea
9 Replies
LEARN ABOUT OSF1
trunc
floor(3) Library Functions Manual floor(3)NAME
floor, ceil, modf, nint, rint, trunc - Round floating-point numbers to floating-point integers, return the nearest integral value, and
truncate a floating-point number
LIBRARY
Math Library (libm.a)
SYNOPSIS
#include <math.h>
double floor (double x);
float floorf (float x);
long double floorl (long double x);
double ceil (double x);
float ceilf (float x);
long double ceill (long double x);
double modf (double x, double *n);
float modff (float x, float *n);
long double modfl (long double x, long double *n);
double nint (double x);
float nintf (float x);
long double nintl (long double x);
double rint (double x);
float rintf (float x);
long double rintl (long double x);
double trunc (double x);
float truncf (float x);
long double truncl (long double x);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
floor(): XPG4
ceil(): XPG4
modf(): XPG4
rint(): XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
DESCRIPTION
The floor(), floorf(), and floorl() functions return the largest floating-point integer value less than or equal to x.
The ceil(), ceilf(), and ceill() functions return the smallest floating-point integer value greater than or equal to x.
The modf(), modff(), and modfl() functions split a floating-point number x into a fractional part f and an integer part i such that |f| <
1.0 and (f + i) = x. Both f and i have the same sign as x. The modf(), modff(), and modfl() functions return f and store i into the loca-
tion pointed to by n.
The nint(), nintf(), and nintl() functions return the nearest integral value to x, except halfway cases are rounded to the integral value
larger in magnitude. This corresponds to the FORTRAN generic intrinsic function nint().
The rint(), rintf(), and rintl() functions round x to an integral value according to the current IEEE rounding direction specified by the
user.
The trunc(), truncf(), and truncl() functions truncate x to an integral value. delim off
floor(3)