Mathematical rounding should always be correct in my opinion
That's the book all about:
A computer can not do true mathematical rounding due to the representation of numbers in a series of bits / bytes.
Mathematical rounding should always be correct in my opinion
lwjwillemsen wrote:Mathematical rounding should always be correct in my opinion
That's the book all about:
A computer can not do true mathematical rounding due to the representation of numbers in a series of bits / bytes.
/**
* Round using exponential notation shifting
*
* @param {Number} value
* @param {Number} precision
*/
function round(value, precision) {
return Number(Math.round(Number(Math.abs(value)+'e'+precision))+'e-'+precision) * (value < 0 ? -1 : 1)
}
omar wrote:
- Code: Select all
/**
* Round using exponential notation shifting
*
* @param {Number} value
* @param {Number} precision
*/
function round(value, precision) {
return Number(Math.round(Number(Math.abs(value)+'e'+precision))+'e-'+precision) * (value < 0 ? -1 : 1)
}
Return to Programming with Servoy
Users browsing this forum: No registered users and 6 guests