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).
Comparisons between
stringvalues andfloatvalues behave differently than those betweenstringvalues andintvalues.More precisely,
intvalues can reliably compared tostringvalues, as the implicit conversion is performed correctly. However, this is not the case forfloatvalues. This is due to the usage ofsprintfto perform the conversion (for example, lines 185-189 of src/buzz/buzztype.c).Code to reproduce:
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).