buzz-lang / Buzz

A programming language designed for robot swarms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistencies in float/string vs int/string comparisons

samarseneault opened this issue · comments

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).