![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Floating point error in C | Hara | High Level Programming | 2 | 06-18-2008 02:43 AM |
| Rounding off the value of Floating point value | damansingh | Shell Programming and Scripting | 7 | 05-21-2008 06:46 AM |
| Floating point exception !!! | ssk01 | Linux | 2 | 05-14-2008 02:58 AM |
| floating point problem | vijlak | High Level Programming | 4 | 03-08-2007 01:18 AM |
| Floating Point Division | gsatch | Shell Programming and Scripting | 1 | 07-25-2002 01:03 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
floating point addition
hi,
I have a file like this 10.456 123.567 456.876 234.987 ........ ....... What i want to do is ia have to add all those numbers and put the result in some other file. Any help pls. cheers RRK |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
awk ' { num += $0 } END { printf("%f",num) }' file
Code:
echo $(tr '\n' '+' < file)"0" | bc |
|
#3
|
|||
|
|||
|
Hi,
When i use the following command,I am getting the following error. echo $(tr '\n' '+' < numbers "0" ) | bc error:Parsing error. any help cheers RRK |
|
#4
|
|||
|
|||
|
String "0" should be outside $(...)
Code:
echo $(tr '\n' '+' < numbers )"0" | bc Code:
$(tr '\n' '+' < numbers ) For ex: Code:
10.456+123.567+456.876+234.987+ |
|
#5
|
|||
|
|||
|
hi,
I used the following command echo $(tr '\n' '+' < numbers )"0" | bc But now also it is giving the same error-"Parse error". cheers RRK |
|
#6
|
|||
|
|||
|
Can you show the output of echo $(tr '\n' '+' < numbers )"0" ?
|
|
#7
|
|||
|
|||
|
yes,here is the output :
10.45+11.34+12.87+13.45+14.45++0 |
|||
| Google The UNIX and Linux Forums |