In this case, must be very good to understand the bitwise &.
Let the number of state and consists of N bits. Then this number can carry information about the N errors if the i-th bit in the number is equal to 1-error, 0 - no.
In this case, if state&(constant)!=0, then there was an error.
ios::badbit is a constant responsible for the error as a function of bad
ios::failbit - as does the function fail
In the variable errno is written to the error reading variable. ERANGE error - occurs when we read into a variable a value that does not fit into the variable.
Here is a list of read errors - reference