Binary conversion using a stack