Full Discussion: Rounding issue with awk
Rounding issue with awk Post 302339062 by ppat7046 on Wednesday 29th of July 2009 04:01:31 PM
07-29-2009
Got it.

Thank you very much,

Prashant
 ppat7046 View Public Profile for ppat7046 Find all posts by ppat7046

## Rounding off using BC.

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

## Rounding off to the next whole number

Hello, I searched a lot on this Forum. Please help me with the below problem. I want to divide two numbers and the result should be the next nearest whole number. E.G. Dividing 10.8/5 ideally gives 2.16. But the result should be 3 i.e. rounded off to the next whole number. Any help will...

## Annoying rounding issue in awk

Hello I am getting this very annoying issue in awk: awk '{a=12825;b=a*1.25; print b}' test 16031.2 Thing is the multiplication result is wrong... Result should be 16031.25. I think the issue only happens on bigger numbers. What can I do to get passed this? Thanks by advance

## Rounding Script Help

I need some help with my rouding script. I have started pretty much from scratch and have no idea if its correct or even close but I have been trying and have gotten to this point. i keep getting syntax errors and im not sure what is wrong. Here is what I got let value=\$1; while do let...

## AWK rounding up numbers

Hi, I have managed to round up numbers by using the following command: echo "5.54" | awk '{printf "%.0f\n", \$1}' result 6 How can I round up all the numbers in a column in a file and print the lines with the new calculated totals? Thanks,

## awk, floating point and rounding

I had a person bring an interesting problem to me that appears to involve some sort of rounding inside awk. I've verified this with awk and nawk on Solaris as well as with gawk 3.1.5 on a Linux box. The original code fragment he brought me was thus: for (index=0; index < 1; index=index+.1) ...

## awk calculation automatically rounding off the output

I have some calculation in my script which is similar to the below example . I find that sometimes when using large decimal digits, the output gets automatically rounded off and it is affecting the program. I am not able to understand what is happening here.. awk '{ a=6.32498922 a1=6.324...

## printf (awk,perl,shell) float rounding issue

Hi guys, could someone throw some light on the following behaviour of printf (I'll start with info about the system and the tool/shell/interpreter versions)?: \$ uname -a Linux linux-86if.site 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64...

## Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The...

## [awk] rounding a float number?

Heyas Trying to calculate the total size of a file by reading its bitrate. Code snippet: fs_expected() { # # Returns the expected filesize in bytes # pr_str() { ff=\$(cat \$TMP.info) d="\${ff#*bitrate: }" echo "\${d%%,*}" | \$AWK '{print \$1}' | head -n 1 } t_BYTERATE=\$((...
```IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files

SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ...
igawk [ all gawk options ] [ -- ] program-text file ...

DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1).

AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like

@include getopt.awk

in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path.

OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports.

EXAMPLES
cat << EOF > test.awk
@include getopt.awk

BEGIN {
while (getopt(ARGC, ARGV, "am:q") != -1)
...
}
EOF

igawk -f test.awk