01-16-2015
Hi ongoto,
Did you even look at the problem statement for this thread: "How to round off a decimal number to higher whole number using ceil command in unix?"
Using printf is great if you want to round to the nearest integer. It is not even close to providing something that calculates the ceiling of a decimal number.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am currently using tcsh
I am trying to round a decimal number to the ten-thousandths place
For instance:
1.23456 is rounded up towards 1.2346
I am not looking for truncation, but for rounding. Anyone know how to do this with awk or expr?
Thanks (2 Replies)
Discussion started by: miniwheats
2 Replies
2. UNIX for Dummies Questions & Answers
Anybody please help me...
Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary Coded Decimal) representation. Also, draw its Flow Chart.
This is a unix qn...
plz post algorithm for that :confused: (1 Reply)
Discussion started by: caramba
1 Replies
3. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary... (2 Replies)
Discussion started by: caramba
2 Replies
4. Shell Programming and Scripting
Hi Friends,
This is my last post for today.
My input file is
chr1 100 200
chr1 123 300
chr1 300 400
chr1 420 520
chr10 132344343 132348674
When I try using this command
awk '{v=($3+$2)/2; print $0"\t"v}' 1
This is my output
chr1 100 200 150
chr1 123 300 211.5 (2 Replies)
Discussion started by: jacobs.smith
2 Replies
5. Shell Programming and Scripting
I have a number in a bash variable n, and want to round it to 2 decimal places. How can I do that?
n=0.0867268
Need to have
num=0.09 (1 Reply)
Discussion started by: kristinu
1 Replies
6. Shell Programming and Scripting
Hi,
I wanted to round all the values in a column to nearest integer. I have multiple files with only two columns and I want to round values in column 2. e.g
input_file
A1 23.971578 A2 34.624976 A3 46.403446 A4 375 A5 1 A6 3 A7 ... (3 Replies)
Discussion started by: ashu0001
3 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I want to convert two hexadecimal numbers to decimal using unix command line.
1cce446295197a9d6352f9f223a9b698
fc8f99ac06e88c4faf669cf366f60d
I tried using
`echo "ibase=16; $no |bc`
printf '%x\n' "1cce446295197a9d6352f9f223a9b698"
but it doesn't work for such big number it... (4 Replies)
Discussion started by: sudhakar T
4 Replies
8. Programming
Hi ,
seq can be 0...128
int windex = seq / 8;
int bindex = seq % 8;
unsigned char bitvalue = '\x01' << (7-bindex) ;
bpv.bitmapvalue = bitvalue;
This is the part of a program to convert decimal to bitmap value of hexadecimal.
I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies
9. Shell Programming and Scripting
I used the below script to Sum up a field in a file based on some unique values. But the problem is when it is summing up the units, it is truncating to 2 decimals and not 6 decimals as in the input file (Input file has the units with up to 6 Decimals – Sample data below, when the units in the 2... (4 Replies)
Discussion started by: brlsubbu
4 Replies
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)