## Decimals in TCSH

 decimal, loop, non-integer, shell scripts, tcsh Decimals in TCSH
Decimals in TCSH

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
RI now runs from 10 to 30 but PI is only ever 1, 2 or 3. Any ideas?
Thanks

Last edited by Scott; 01-22-2010 at 06:11 AM.. Reason: Please use code tags
 DFr0st View Public Profile for DFr0st Find all posts by DFr0st
Hi.

Here's one alternative:
producing:
See Floating Point for a brief explanation of the alias.

Note that many people will advise you to avoid tcsh scripting. Using Bourne-shell relatives seems to work best for most projects. Here's an example of zsh illustrating built-in floating-point arithmetic (in later versions of ksh as well):
producing:
Best wishes ... cheers, drl
 drl View Public Profile for drl Find all posts by drl

Test Your Knowledge in Computers #363
Difficulty: Medium
uudecode originated in Version 1 AT&T UNIX.
True or False?

## how to find the field has more than 2 decimals

Hi Gurus, I have below sample file, I need find the line which 2rd field has more than 2 decimals. in sample file, I need to find xyz, 123456.789 abc, 1234.45, def xyz, 123456.789, xxx bce, 1234.34, xxx thanks in advance

## Getting date in seconds with decimals

I am trying to get date to display decimal Desired output 1350386096256.12 I know this can be done with printf, but are not able to make it work. I have tested this and many otherprintf "%.2f" \$((\$(date +%s%N)/1000000))

## Round up the decimals

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

## Regarding Decimals in Cshell

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...

## convert Regular decimals to Packed decimals

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...

## removing and rounding up decimals

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.

## Bourne and decimals??

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?

## handle decimals

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?

## Multiplying Floats/Decimals

Is there a way that i can get something like this to work: Number=`expr 80 \* 10.69` i.e. To multiply an integer by a decimal or a decimal by a decimal etc...? thanks

## comparing two numbers with the decimals

Can someone tell me how do I comapre two numbers with the decimals in UNIX shell scripting I understand "-gt" can be used only for integers Regards, Giri