2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2017-10-06 03:52:41 +00:00
|
|
|
/**
|
2018-04-24 06:23:26 +00:00
|
|
|
* Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down.
|
2017-10-06 03:52:41 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Math.RoundAwayFromZero
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-24 06:23:26 +00:00
|
|
|
* @param {number} value - The number to round.
|
2017-10-06 03:52:41 +00:00
|
|
|
*
|
2018-04-24 06:23:26 +00:00
|
|
|
* @return {number} The rounded number, rounded away from zero.
|
2017-10-06 03:52:41 +00:00
|
|
|
*/
|
2016-12-07 17:16:59 +00:00
|
|
|
var RoundAwayFromZero = function (value)
|
|
|
|
{
|
|
|
|
// "Opposite" of truncate.
|
|
|
|
return (value > 0) ? Math.ceil(value) : Math.floor(value);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = RoundAwayFromZero;
|