Skip to content

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

Description

@samarseneault

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions