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

Math Operations Don't Fully Handle Big Numbers #483

Open
microalps opened this issue May 5, 2022 · 1 comment · May be fixed by #488
Open

Math Operations Don't Fully Handle Big Numbers #483

microalps opened this issue May 5, 2022 · 1 comment · May be fixed by #488
Assignees

Comments

@microalps
Copy link
Contributor

Dotliquid version

2.2.614

Expected behavior

Math functions around the integer boundary should work, for example adding 1 to int.MaxValue

Actual behavior

Liquid error: Arithmetic operation resulted in an overflow.

Steps to reproduce the Problem (you can add files)

    public void TestPlusNumericBoundary()
    {
        Helper.AssertTemplateResult(
            expected: "2147483648",
            template: "{{ big | plus: 1 }}",
            localVariables: Hash.FromAnonymousObject(new { big = int.MaxValue }));

        Helper.AssertTemplateResult(
            expected: "79228162514264337593543950336",
            template: "{{ big | plus: 1 }}",
            localVariables: Hash.FromAnonymousObject(new { big = decimal.MaxValue }));
    }
@microalps
Copy link
Contributor Author

https://replit.com/@microalps/LiquidMathStrings#main.rb shows that ruby liquid works with large numbers. That is because natively ruby handles type conversion and doesn't throw an overflow or wrap around.

daviburg added a commit that referenced this issue May 9, 2022
@daviburg daviburg linked a pull request May 9, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants