Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
round.awk34 linesDownload Raw Back to awk
1# round.awk --- do normal rounding2#3# This file and how to use it are described in the manual.4# Therefore, we respectfully advise you to Read The Fine Manual5# for more information.6#7# Arnold Robbins, arnold@skeeve.com, Public Domain8# August, 19969 10function round(x,   ival, aval, fraction)11{12   ival = int(x)    # integer part, int() truncates13 14   # see if fractional part15   if (ival == x)   # no fraction16      return ival   # ensure no decimals17 18   if (x < 0) {19      aval = -x     # absolute value20      ival = int(aval)21      fraction = aval - ival22      if (fraction >= .5)23         return int(x) - 1   # -2.5 --> -324      else25         return int(x)       # -2.3 --> -226   } else {27      fraction = x - ival28      if (fraction >= .5)29         return ival + 130      else31         return ival32   }33}34 
codekingpro/portable-devtools · Team Ai