You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Had the same problem with JS in-built round method. Found this workaround (see link in the JSDOC) which could be helpful for your case, too?
/**
* Helper method: round.
*
* It rounds a given number to a given number of decimal places.
* JS in-built round-method is sometimes not correct,
* see: {@link http://www.jacklmoore.com/notes/rounding-in-javascript/}.
*
* @param {number} value The given input value to be rounded.
* @param {number} decimals The given number of decimal places to round to.
* @returns {number} The rounded number.
*/
round(value: number, decimals: number): number {
if (Number.isNaN(value)) {
return;
}
return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals);
}
Think about using a lib like https://www.npmjs.com/package/js-big-decimal to handle precision in decimal numbers so we do not loose information.
see #115 (comment)
remove https://github.com/dasch-swiss/knora-api-js-lib/blob/8eafba8796e536449253af1e12019bdde92bd1de/src/api/v2/resource/resources-endpoint.spec.ts#L243-L244
The text was updated successfully, but these errors were encountered: