Skip to content

[C] AppendDouble doesn't work with most floats #75

@lidavidm

Description

@lidavidm

AppendDouble checks that the value is in the range [FLT_MIN, FLT_MAX] before appending. However, that's not actually the right check: FLT_MIN isn't the "minimum float value" (that doesn't make sense; floats contain infinity), but rather the smallest positive float. Hence, 0 and any negative float will get wrongly rejected.

IMO, it might make sense to just accept any double and cast it to float without thinking. Otherwise, maybe the right check is (double)((float) v) == v or something ("is this double exactly representable as a float", perhaps there's an idiom for this though I can't get the right search query to figure this out), though this will not work for NaN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions