From df9476c40a4fef62cd0e1e1c9052afa82e01e3ad Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 22 Sep 2017 11:39:41 -0800 Subject: [PATCH] Util.roundSymmetric for Math.round, https://github.com/phetsims/fluid-pressure-and-flow/issues/298 --- js/flow/model/FlowModel.js | 5 +++-- js/watertower/model/WaterTowerModel.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/flow/model/FlowModel.js b/js/flow/model/FlowModel.js index 8fd1933b..5173f647 100644 --- a/js/flow/model/FlowModel.js +++ b/js/flow/model/FlowModel.js @@ -27,6 +27,7 @@ define( function( require ) { var Sensor = require( 'FLUID_PRESSURE_AND_FLOW/common/model/Sensor' ); var StringUtils = require( 'PHETCOMMON/util/StringUtils' ); var Units = require( 'FLUID_PRESSURE_AND_FLOW/common/model/Units' ); + var Util = require( 'DOT/Util' ); var Vector2 = require( 'DOT/Vector2' ); var VelocitySensor = require( 'FLUID_PRESSURE_AND_FLOW/common/model/VelocitySensor' ); @@ -258,7 +259,7 @@ define( function( require ) { (Units.FLUID_DENSITY_ENGLISH_PER_METRIC * this.fluidDensityProperty.value).toFixed( 2 ), densityUnitsEnglishString ); } else { - return StringUtils.format( valueWithUnitsPatternString, Math.round( this.fluidDensityProperty.value ), densityUnitsMetricString ); + return StringUtils.format( valueWithUnitsPatternString, Util.roundSymmetric( this.fluidDensityProperty.value ), densityUnitsMetricString ); } }, @@ -273,7 +274,7 @@ define( function( require ) { (Units.FLUID_FlOW_RATE_ENGLISH_PER_METRIC * this.pipe.flowRateProperty.value).toFixed( 2 ), rateUnitsEnglishString ); } else { - return StringUtils.format( valueWithUnitsPatternString, Math.round( this.pipe.flowRateProperty.value ), rateUnitsMetricString ); + return StringUtils.format( valueWithUnitsPatternString, Util.roundSymmetric( this.pipe.flowRateProperty.value ), rateUnitsMetricString ); } }, diff --git a/js/watertower/model/WaterTowerModel.js b/js/watertower/model/WaterTowerModel.js index 4d06d30e..43953cc7 100644 --- a/js/watertower/model/WaterTowerModel.js +++ b/js/watertower/model/WaterTowerModel.js @@ -370,7 +370,7 @@ define( function( require ) { (Units.FLUID_DENSITY_ENGLISH_PER_METRIC * this.fluidDensityProperty.value).toFixed( 2 ), densityUnitsEnglishString ); } else { - return StringUtils.format( valueWithUnitsPatternString, Math.round( this.fluidDensityProperty.value ), densityUnitsMetricString ); + return StringUtils.format( valueWithUnitsPatternString, Util.roundSymmetric( this.fluidDensityProperty.value ), densityUnitsMetricString ); } },