08-26-2008
absolute value
is there any function in unix which will convert a integer to absolute value with a single decimal point.
suppose x=15232
y=x/1024=14.875
i want y to be 14.8
Similarly if y=6.29452 it should come as 6.3
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am trying to find out how to get an absolute value for integer in ksh.
I tried using abs... but that doesn't work ! this is the workaround I did, but isn't there an inbuilt function to get absolute value for any variable !
Please help as i am new to unix :confused:
Thanks,
... (3 Replies)
Discussion started by: icyhot
3 Replies
2. Shell Programming and Scripting
How would I get the absolute filename of a selected file...I want to control click...I already have the context menu all set to run a script...I just need to be able to get the file name of the file I control clicked on.
In windows it is as follows:
set filename=%~f1
set name=%~n1
set... (0 Replies)
Discussion started by: mainegate
0 Replies
3. UNIX for Dummies Questions & Answers
is cd ~ considered an absolute path? (2 Replies)
Discussion started by: Kirichiko
2 Replies
4. Shell Programming and Scripting
Is there a function in awk to get the absolute value of a-b which can be negative or positive, I just care for the absolute value... (5 Replies)
Discussion started by: placroix1
5 Replies
5. Shell Programming and Scripting
Hi,
i want to caluculate sum and absolute sum information of the 2nd column.
sum(abs(ENO)),sum(ENO)
file1 contains the employee information.
"abc","+10000.00","100"
"bbc","-3000.00","400"
"cbc","+20000.90","500"
"dbc","-4000.00","600"
output should get this
Sum(abs(eno)) ... (5 Replies)
Discussion started by: onesuri
5 Replies
6. Shell Programming and Scripting
Hi,
I have a file as follows:
|-30.0|Appls. executing in db manager currently = 2
|-80.0|Locks held currently = 1
| 90.0|High water mark (bytes) = 65536
|-50.0|Configured size (bytes) = 16777216
|-100.0|Current size (bytes) ... (6 Replies)
Discussion started by: sudvishw
6 Replies
7. UNIX for Dummies Questions & Answers
I have a big file with 127 columns and 869 rows. What I am trying to do is to get the absolute value of all numbers in the file, and then get the maximum of each column.
If this was for one column it wouldn't be a problem, I would use:
awk '{ print ($1 >= 0) ? $1 : 0 - $1}' file > out1... (3 Replies)
Discussion started by: cosmologist
3 Replies
8. Shell Programming and Scripting
None know if exists a function/command that get the absolute value for a number?
Thanks:) (14 Replies)
Discussion started by: Steph85
14 Replies
9. Shell Programming and Scripting
Hello All,
I am using following awk command in my shell script. I want to compare the value in column 2 and colum 3 after taking their absolute value. Column $2 and $3 can have any value positive or negative or both.
awk -F"|" '{print $0,($2>$3?"F":"T")}' OFS='|' myfile.txt
Your help... (2 Replies)
Discussion started by: angshuman
2 Replies
LEARN ABOUT OPENSOLARIS
decimal_to_double
decimal_to_floating(3C) Standard C Library Functions decimal_to_floating(3C)
NAME
decimal_to_floating, decimal_to_single, decimal_to_double, decimal_to_extended, decimal_to_quadruple - convert decimal record to floating-
point value
SYNOPSIS
#include <floatingpoint.h>
void decimal_to_single(single *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);
void decimal_to_double(double *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);
void decimal_to_extended(extended *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);
void decimal_to_quadruple(quadruple *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);
DESCRIPTION
These functions convert the decimal record *pd to a floating-point value *px observing the rounding direction specified in *pm and setting
*ps to reflect any floating-point exceptions that occur.
When pd->fpclass is fp_zero, fp_infinity, fp_quiet, or fp_signaling, *px is set to zero, infinity, a quiet NaN, or a signaling NaN, respec-
tively, with the sign indicated by pd->sign. All other fields in *pd are ignored.
When pd->fpclass is fp_normal or fp_subnormal, pd->ds must contain a null-terminated string of one or more ASCII digits representing a non-
zero integer m, and pd->ndigits must be equal to the length of this string. Then *px is set to a correctly rounded approximation to
-1**(pd->sign) * m * 10**(pd->exponent)
pd->more can be set to a non-zero value to indicate that insignificant trailing digits were omitted from pd->ds. In this case, m is
replaced by m + delta in the expression above, where delta is some tiny positive fraction.
The converted value is rounded according to the rounding direction specified in pm->rd. pm->df and pm->ndigits are not used.
On exit, *ps contains a bitwise OR of flags corresponding to any floating-point exceptions that occurred. The only possible exceptions are
underflow, overflow, and inexact. If no floating-point exceptions occurred, *ps is set to zero.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
scanf(3C), string_to_decimal(3C), strtod(3C), attributes(5)
SunOS 5.11 1 Oct 2001 decimal_to_floating(3C)