Task

Express a number in decimal as a fixed-length string with leading zeros.



For example, the number   7.125   could be expressed as   00007.125.




 
concept FixedLengthFormat(value, length) {
	string = text(abs(value))
	prefix = ""
	sign = ""
 
	if value < 0
		sign = "-"
	end
 
	if #string < length
		prefix = "0"*(length-#sign-#string-#prefix)
	end
 
	return sign+prefix+string
}
 
software {
	d = 7.125
	print(FixedLengthFormat(d, 9))
	print(FixedLengthFormat(-d, 9))
}
 