cpp implementation of valid number

There are lots of detailed rules to form a valid number, exhausting