you could merge 1st and second if to: if value == 0 || value == 1 then os << value