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

Inconsistencies in float/string vs int/string comparisons #104

Open
samarseneault opened this issue Mar 9, 2022 · 0 comments
Open

Inconsistencies in float/string vs int/string comparisons #104

samarseneault opened this issue Mar 9, 2022 · 0 comments
Assignees
Labels

Comments

@samarseneault
Copy link
Collaborator

Comparisons between string values and float values behave differently than those between string values and int values.
More precisely, int values can reliably compared to string values, as the implicit conversion is performed correctly. However, this is not the case for float values. This is due to the usage of sprintf to perform the conversion (for example, lines 185-189 of src/buzz/buzztype.c).

Code to reproduce:

function init() {
    log(-9 == "-9")        # Result: 1
    log(-9.0 == "-9.0")    # Result: 0
    log(-9 == -9.0)        # Result: 1
}

Associated test suite: TEST(BuzzObjCompare, String) in src/testing/unittest/buzztype_test.cpp (instructions on how to run the tests are provided in src/testing/unittest/README.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant