From 03ea4a35e8f00277de2475dc4dfb941f6bee73eb Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 24 Jun 2010 05:22:56 +0000 Subject: [PATCH] (web) Math.roundWithPrecision does the exact same thing as toFixed. --- web/javascript/common.js | 12 ------------ web/javascript/formatter.js | 14 +++++++------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/web/javascript/common.js b/web/javascript/common.js index f62154940..c2e1a70c7 100644 --- a/web/javascript/common.js +++ b/web/javascript/common.js @@ -107,18 +107,6 @@ function setInnerHTML( e, html ) } }; -/* - * Round a float to a specified number of decimal - * places, stripping trailing zeroes - * - * @param float floatnum - * @param integer precision - * @returns float - */ -Math.roundWithPrecision = function(floatnum, precision) { - return Math.round( floatnum * Math.pow ( 10, precision ) ) / Math.pow( 10, precision ); -}; - /* * Given a numerator and denominator, return a ratio string */ diff --git a/web/javascript/formatter.js b/web/javascript/formatter.js index 8b5ee5c2a..98161eefe 100644 --- a/web/javascript/formatter.js +++ b/web/javascript/formatter.js @@ -72,22 +72,22 @@ Transmission.fmt = (function() return 'None'; if( bytes < KB_val ) - return bytes.toFixed(0) + ' B'; + return bytes.toFixed(10) + ' B'; if( bytes < ( KB_val * 100 ) ) - return Math.roundWithPrecision(bytes/KB_val, 2) + ' ' + KB_str; + return (bytes/KB_val).toFixed(2) + ' ' + KB_str; if( bytes < MB_val ) - return Math.roundWithPrecision(bytes/KB_val, 1) + ' ' + KB_str; + return (bytes/KB_val).toFixed(1) + ' ' + KB_str; if( bytes < ( MB_val * 100 ) ) - return Math.roundWithPrecision(bytes/MB_val, 2) + ' ' + MB_str; + return (bytes/MB_val).toFixed(2) + ' ' + MB_str; if( bytes < GB_val ) - return Math.roundWithPrecision(bytes/MB_val, 1) + ' ' + MB_str; + return (bytes/MB_val).toFixed(1) + ' ' + MB_str; if( bytes < ( GB_val * 100 ) ) - return Math.roundWithPrecision(bytes/GB_val, 2) + ' ' + GB_str; + return (bytes/GB_val).toFixed(2) + ' ' + GB_str; else - return Math.roundWithPrecision(bytes/GB_val, 1) + ' ' + GB_str; + return (bytes/GB_val).toFixed(1) + ' ' + GB_str; }, speed: function( bytes )