Skip to content

Conversion from string to numbers doesn't follow POSIX specification #110

@bertysentry

Description

@bertysentry

Scalar variables in AWK can be either string, number or... strnum. See gawk's manual.

Conversion (especially in comparison and mathematical operations) is governed by these types as in the below table:

STRING NUMERIC STRNUM
STRING string string
NUMERIC string numeric
STRNUM string numeric

Jawk doesn't implement strnum and evaluates dynamically when to convert a String to a Number, and vice versa.

Consequence: the below script prints 1 with Jawk, while it should print 0 as with gawk:

BEGIN { r = 2 == "2.0"; print r }

More information can be found here (see the section "Expressions in awk")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions