09-11-2008
thanks guys, works great
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello again.
I'm trying to use BC to calculate some numbers in a shell script.
I want to have the numbers rounded off to 1 decimal place.
for example:
initsize=1566720
zipsize=4733
I'm trying to get the ratio between them. the equation is:
(($initsize-$zipsize)/$initsize)*100
so... (3 Replies)
Discussion started by: noodlesoup
3 Replies
2. UNIX for Dummies Questions & Answers
Hi,
Can any one help me in finding a solution for rounding off to 2 decimal places.
I am using the following code:
VAR1=.01292105263157894736
VAR2=`echo "scale=2; $VAR1 * 100" | bc -l`
The result I 'm getting is
1.29210526315789473600
But I need the output as 1.29
Thanks
Shash (2 Replies)
Discussion started by: shash
2 Replies
3. Shell Programming and Scripting
Hi All,
How we can handle decimals in (Float) in UNIX.
a=73
b=5
c=`expr a / b`
i am getting 14 but i need full 14.6 .
Can any one help me pls? (1 Reply)
Discussion started by: subin_bala
1 Replies
4. Shell Programming and Scripting
I need to get 15% of the variable exer1 to be added to other exercises
so far, i've got
exer1=$1
aver=`expr $exer \* .15`
but i keep getting an error that an integer value was expected. Is there anyway around this? (1 Reply)
Discussion started by: kdyzsa
1 Replies
5. Shell Programming and Scripting
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)
Discussion started by: mgirinath
2 Replies
6. Shell Programming and Scripting
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)
Discussion started by: rdlover
9 Replies
7. Shell Programming and Scripting
Hello,
I want to run a loop with non-integer values (which I know I can't) so I've created a loop of integers and divided it by 10. However, these values are always rounded down to 1 significant figure. How do I get the script to keep and use the decimal value?
My script is as follows
#... (1 Reply)
Discussion started by: DFr0st
1 Replies
8. UNIX for Dummies Questions & Answers
Hello...
I am new to unix and I am wondering if in a C-shell script , Are we supposed to use only whole numbers........ for example..if a program needs to calculate the average of some numbers........
@ avg = (($1 +$2 + $3)/3)) is returning a whole number.........How can a decimal be achieved... (1 Reply)
Discussion started by: ravindra22
1 Replies
9. Shell Programming and Scripting
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)
Discussion started by: Gery
9 Replies
10. Shell Programming and Scripting
Hi All,
I would like to do the following in the shell script
561.76 to 562
I tried using this echo 'scale=0; 749 * 75 /100 ' | bc
but just returned only 561
Please help me . I appreciate your help
Thanks
rajeevm (13 Replies)
Discussion started by: rajeevm
13 Replies
LEARN ABOUT OSF1
write_rnd
write_rnd(3) Library Functions Manual write_rnd(3)
NAME
write_rnd, read_rnd - Sets and returns IEEE dynamic rounding mode for floating-point operations
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <float.h>
unsigned int write_rnd(
unsigned int rnd);
unsigned int read_rnd();
DESCRIPTION
The write_rnd function sets the dynamic rounding mode in the floating-point control register (fpcr) for IEEE floating-point operations and
returns the previous dynamic rounding mode. Dynamic rounding mode for IEEE floating-point operations is enabled for code generated by the
C compiler by specifying -fprm d to cc(1), and by using the d floating-point instruction operator in assembly language code.
Specify rnd as one of the following constants defined in float.h
---------------------------------------------------
Constant Meaning
---------------------------------------------------
FP_RND_RZ Round toward zero (chopped rounding)
FP_RND_RN Round toward nearest (normal rounding)
FP_RND_RP Round toward plus infinity
FP_RND_RM Round toward minus infinity
---------------------------------------------------
The read_rnd function returns the current dynamic rounding mode for floating-point operations.
RETURN VALUES
The write_rnd function returns the previous IEEE floating-point rounding mode. The read_rnd function returns the current IEEE floating-
point rounding mode.
RELATED INFORMATION
Commands: cc(1).
Files: float.h.
Assembly Language Programmer's Guide.
Alpha Architecture Reference Manual.
IEEE Standard for Binary Floating-Point Arithmetic delim off
write_rnd(3)