Skip to content

strings.lua test fails due to string.format(10.3) is not culture invariant, thus printing "10,3" #116

@CodeSmile-0000011110110111

Description

When I run strings.lua test it fails in this line:

assert(tonumber(string.format("%f", 10.3)) == 10.3)

I added a print before that line to see what the output is:

print("10.3 as string is: " .. string.format("%f", 10.3) .. " and as number: " .. tostring(tonumber(string.format("%f", 10.3))))

Output:
10.3 as string is: 10,3 and as number: nil

Meaning string.format prints the number in a culture-specific (here: de-DE) way and tonumber is unable to handle culture-specific conversion (comma as decimal character).

Not sure what the Lua library does but I place my bet that string.format should be culture-invariant and thus always print "10.3".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions