def execute(state)
width = param(0, state, nil)
digits = param(1, state, nil)
scale = param(2, state, 0)
overflowchar = param(3, state, nil)
padchar = param(4, state, ?\s)
arg = state.next_arg
if arg.respond_to? :to_f
num = arg.to_f * (10 ** scale)
str = (at_mod? and num >= 0) ? '+' : ''
str = sign + (digits.nil? ? num.to_s : sprintf("%.#{digits}f",num))
str = sign + sprintf("%.#{$1}f", num) if str =~ /e-([0-9]+)$/
unless width.nil?
if not digits.nil? and width == digits + 1
str.sub!(/^([+-]?)0\./, '\1.')
end
str = str.rjust(width, padchar.chr) if str.length < width
if str.length > width and digits.nil?
prec = width - (str.index(/\./) + 1)
str = sign + sprintf("%#.#{prec}f", num)
end
str.sub!(/\.$/, '') if str.length > width and digits.nil?
if str.length > width and not overflowchar.nil?
str = overflowchar.chr * width
end
end
state.output str
elsif arg.respond_to? :to_int
state.push_back_arg
parameters = @params[0].nil? ? [] : [@params[0]]
Factory.build(parameters, [], ?D, nil, @pos).execute(state)
else
arg_error 'argument is not a number or a number string'
end
end