![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Floating point error in C | Hara | High Level Programming | 2 | 06-18-2008 06:43 AM |
| Rounding off the value of Floating point value | damansingh | Shell Programming and Scripting | 7 | 05-21-2008 10:46 AM |
| How to Compare Floating point / real numbers | padarthy | Shell Programming and Scripting | 13 | 09-24-2007 09:03 PM |
| floating point problem | vijlak | High Level Programming | 4 | 03-08-2007 04:18 AM |
| Floating Point Division | gsatch | Shell Programming and Scripting | 1 | 07-25-2002 05:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
problem with floating point numbers in awk
hi all, i have the following problem using awk in a script
i want to read the values from a column with real numbers and calculate the mean.the problem is that when i use a statement such as this num = $4 i cant find a way to convert the variable from string to floating point to perform any operations.i tried the following sum = num + 0.0 but sum is equal to 0 after this statement, num is not treated as floating point number but as string any help would be appreciated edit : i am using awk 3.1.4 on Suse 9.2 |
|
||||
|
i just want to do simple mathematical operations.to be more clear here is a test awk script i used
BEGIN{} { num = $1 sum += num } END { print sum } where column 1 contains the floating point numbers print sum produces 0... i tried to add 0.0 to num to force to be treated as number and not as string but that didnt work either |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|