Skip to content

DataTypeClass does not discriminate between signed and unsigned integers #77

@Jacobfaib

Description

@Jacobfaib

Describe the bug

Writing a uint32 array to disk, then reading it back with HighFive returns a int32 array.

inline DataTypeClass DataType::getClass() const {
    return convert_type_class(detail::h5t_get_class(_hid));
}

(https://github.com/highfive-devs/highfive/blob/main/include/highfive/bits/H5DataType_misc.hpp#L36-L38)

inline DataTypeClass convert_type_class(const H5T_class_t& tclass) {
    switch (tclass) {
    case H5T_TIME:
        return DataTypeClass::Time;
    case H5T_INTEGER:
        return DataTypeClass::Integer;
        ...

(https://github.com/highfive-devs/highfive/blob/main/include/highfive/bits/H5DataType_misc.hpp#L365)

convert_type_class() should probably also call H5Tget_sign() in case of integers, then return a new DataTypeClass::UnsignedInteger. Alternatively, could add a DataType::isSigned() member to DataType that queries this information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions