File: strnum2.awk

package info (click to toggle)
goawk 1.29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 10,560 kB
  • sloc: awk: 3,060; yacc: 198; fortran: 189; python: 131; sh: 58; makefile: 12
file content (18 lines) | stat: -rw-r--r-- 477 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
BEGIN {
	split(" 1.234 ", f, "x")	# create a numeric string (strnum) value
	OFMT = "%.1f"
	CONVFMT = "%.2f"

	# Check whether a strnum is displayed the same way before and
	# after force_number is called. Also, should numeric strings
	# be formatted with OFMT and CONVFMT or show the original string value?

	print f[1]	# OFMT
	print (f[1] "")	# CONVFMT

	# force conversion to NUMBER if it has not happened already
	x = f[1]+0

	print f[1]	# OFMT
	print (f[1] "")	# CONVFMT
}