From 1e67fa26ffed3fb5c09563a77676ee5419aaf33d Mon Sep 17 00:00:00 2001 From: erwanlr Date: Thu, 26 Nov 2015 14:12:04 +0000 Subject: [PATCH] Fixes #890 --- lib/common/hacks.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/hacks.rb b/lib/common/hacks.rb index 5eab7cb0..d45b085a 100644 --- a/lib/common/hacks.rb +++ b/lib/common/hacks.rb @@ -101,8 +101,8 @@ end class Numeric def bytes_to_human units = %w{B KB MB GB TB} - e = (Math.log(self)/Math.log(1024)).floor - s = '%.3f' % (to_f / 1024**e) + e = (Math.log(abs)/Math.log(1024)).floor + s = '%.3f' % (abs.to_f / 1024**e) s.sub(/\.?0*$/, ' ' + units[e]) end end