Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding number without "Round half to even" #671

Open
tomaskodaj opened this issue Feb 5, 2024 · 0 comments
Open

Rounding number without "Round half to even" #671

tomaskodaj opened this issue Feb 5, 2024 · 0 comments

Comments

@tomaskodaj
Copy link

tomaskodaj commented Feb 5, 2024

Is it possible to introduce standard mathematical round function, or introduce switch to change behavior of $round()

Expected output:

$roundX(11.5) => 12
$roundX(12.5) => 13

We are using jsonata for financial calculations where current behavior is not desired and we have to do obscure transformations because of current behavior :(

Thanks

Docs:

This function uses the Round half to even strategy to decide which way to round numbers that fall exactly between two candidates at the specified precision. This strategy is commonly used in financial calculations and is the default rounding mode in IEEE 754.

$round(11.5) => 12
$round(12.5) => 12

SRC:
https://github.com/jsonata-js/jsonata/blob/master/src/functions.js#L1303

@tomaskodaj tomaskodaj changed the title Rounding numer without "Round half to even" Rounding number without "Round half to even" Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant