Skip to content

Determine if attribute is double or float before read #606

Discussion options

You must be logged in to vote

I think that you can get the size of the underlying type with:
https://bluebrain.github.io/HighFive/class_high_five_1_1_data_type.html#a2658ec3c1c3c77dadeb0b1b053d3a7d3

This way you can know if it is float (4 bytes) or double (8 bytes).

if (attribute.getDataType().getClass() == HighFive::DataTypeClass::Float)
{
    if (attribute.getDataType().getSize() == 4) {
        float value;
        attribute.read(value);
    } else if (attribute.getDataType().getSize() == 8) {
        double value;
        attribute.read(value);
    } else {
        std::cerr << "The float type size is not valid." << std::endl;
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wajihullahbaig
Comment options

Answer selected by wajihullahbaig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants