Blame test/addcomma.awk

Packit Service f629e6
# addcomma - put commas in numbers
Packit Service f629e6
#   input:  a number per line
Packit Service f629e6
#   output: the input number followed by
Packit Service f629e6
#      the number with commas and two decimal places 
Packit Service f629e6
Packit Service f629e6
{ printf("%-12s %20s\n", $0, addcomma($0)) }
Packit Service f629e6
Packit Service f629e6
function addcomma(x,   num) {
Packit Service f629e6
 	if (x < 0)
Packit Service f629e6
 	    return "-" addcomma(-x)
Packit Service f629e6
 	num = sprintf("%.2f", x)   # num is dddddd.dd
Packit Service f629e6
 	while (num ~ /[0-9][0-9][0-9][0-9]/)
Packit Service f629e6
 	    sub(/[0-9][0-9][0-9][,.]/, ",&", num)
Packit Service f629e6
 	return num
Packit Service f629e6
}