diff --git a/kernel/common/sprintf.rb b/kernel/common/sprintf.rb
index 8eade59..d63eb25 100644
@@ -179,8 +179,10 @@ module Rubinius
raise ArgumentError, "invalid type (only Fixnum allowed)"
end
- val = (2**(2.size * 8)) + val
- if !flags[:zero] and !precision
+ if !flags[:space] and !flags[:plus]
+ val = (2**(2.size * 8)) + val
+ end
+ if !flags[:zero] and !precision and !flags[:space] and !flags[:plus]
ret = "..#{pad(val, width, precision)}"
else
ret = pad(val, width, precision)
@@ -283,8 +285,11 @@ module Rubinius
ret = val.to_s
modded_width = width.to_i + (flags[:plus] ? 1 : 0)
width = nil if modded_width <= val.to_s.size
- sign = plus_char
-
+ if ret[0] != ?-
+ sign = plus_char
+ else
+ sign = ""
+ end
if precision || flags[:zero]
ret.gsub!("..", "")
end