Sponsored Content
Full Discussion: Rounding off a decimal
Top Forums UNIX for Dummies Questions & Answers Rounding off a decimal Post 302931905 by ongoto on Friday 16th of January 2015 10:08:54 AM
Old 01-16-2015
Quote:
Originally Posted by Don Cragun
Is there some reason why you are so opposed to my suggestion in post #5 in this thread that actually produces the output requested by the OP?
No. I'm not opposing anyone. I'm just offering some options because there is no ceiling command in the shell that I know of. I've found several kludge solutions using Dr. Google; nothing absolute about 'ceiling'. bc is supposed to have a ceil() function, but I can't make it work on my system (Centos).

Since there is no absolute answer for the OP, he deserves some choices. That's all I'm doing here. No challenge to you or anyone else.

Your solution is excellent. I'll leave this thread alone.

Last edited by ongoto; 01-16-2015 at 11:20 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Rounding a decimal

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

Decimal to BCD (Binary Coded Decimal)

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

Decimal to BCD (Binary Coded Decimal)

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

Rounding off decimal values

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

Bash Rounding to 2 decimal places

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

Rounding decimal values in a column

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

Convert hexa decimal to decimal

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

Urgent help needed.. C++ program to convert decimal to hexa decimal

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

Sum the fields with 6 decimal places - getting only 2 decimal places as output

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
pthread_mutex_getprioceiling(3C)										  pthread_mutex_getprioceiling(3C)

NAME
pthread_mutex_getprioceiling, pthread_mutex_setprioceiling - change priority ceiling of a mutex SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ] #include <pthread.h> int pthread_mutex_getprioceiling(const pthread_mutex_t *restrict mutex, int *restrict prioceiling); int pthread_mutex_setprioceiling(pthread_mutex_t *restrict mutex, int prioceiling, int *restrict old_ceiling); The pthread_mutex_getprioceiling() function returns the current priority ceiling of the mutex. The pthread_mutex_setprioceiling() function either locks the mutex if it is unlocked, or blocks until it can successfully lock the mutex, then it changes the mutex's priority ceiling and releases the mutex. When the change is successful, the previous value of the priority ceiling is returned in old_ceiling. The process of locking the mutex need not adhere to the priority protect protocol. If the pthread_mutex_setprioceiling() function fails, the mutex priority ceiling is not changed. The ceiling value should be drawn from the range of priorities for the SCHED_FIFO policy. When a thread acquires such a mutex, the policy of the thread at mutex acquisition should match that from which the ceiling value was derived (SCHED_FIFO, in this case). If a thread changes its scheduling policy while holding a ceiling mutex, the behavior of pthread_mutex_lock() and pthread_mutex_unlock() on this mutex is undefined. See pthread_mutex_lock(3C). The ceiling value should not be treated as a persistent value resident in a pthread_mutex_t that is valid across upgrades of Solaris. The semantics of the actual ceiling value are determined by the existing priority range for the SCHED_FIFO policy, as returned by the sched_get_priority_min() and sched_get_priority_max() functions (see sched_get_priority_min(3RT)) when called on the version of Solaris on which the ceiling value is being utilized. Upon successful completion, the pthread_mutex_getprioceiling() and pthread_mutex_setprioceiling() functions return 0. Otherwise, an error number is returned to indicate the error. The pthread_mutex_getprioceiling() and pthread_mutex_setprioceiling() functions will fail if: ENOSYS The option _POSIX_THREAD_PRIO_PROTECT is not defined and the system does not support the function. Since _POSIX_THREAD_PRIO_PROTECT is defined, this condition is not reported. The pthread_mutex_setprioceiling() function will fail if: EINVAL The mutex was not initialized with its protocol attribute having the value of PTHREAD_PRIO_PROTECT. The pthread_mutex_getprioceiling() and pthread_mutex_setprioceiling() functions may fail if: EINVAL The value specified by mutex does not refer to a currently existing mutex. ENOSYS The system does not support the priority ceiling protocol for mutexes. EPERM The caller does not have the privilege to perform the operation. The pthread_mutex_getprioceiling() function may fail if: EINVAL The priority requested by prioceiling is out of range. The pthread_mutex_setprioceiling() function may fail if: EINVAL The priority requested by prioceiling is out of range. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ pthread_mutex_init(3C), pthread_mutex_lock(3C), sched_get_priority_min(3RT), attributes(5), standards(5) 23 Mar 2005 pthread_mutex_getprioceiling(3C)
All times are GMT -4. The time now is 09:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy