nominal to binary function