Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Re: Validating Hex Numbers

by seattlejohn (Deacon)
on Jan 09, 2003 at 01:11 UTC ( #225407=note: print w/replies, xml ) Need Help??

in reply to Re: Validating Hex Numbers
in thread Validating Hex Numbers

I would definitely *not* check the length of the string if this is intended to be a general-purpose solution. A is a perfectly valid hex number, just as 8 is a valid decimal number.

Of course, in computing contexts single-hex-digit numbers are unusual, but the poster didn't specify what the source or destination of this data is, so I wouldn't want to build in that assumption without additional information.

One thing that the post implies but doesn't make explicit is that "number" really means "non-negative integer". If you want to be truly comprehensive, something like -A8F.C is a valid hex number (namely -2073.75 decimal), but not something most of us likely encounter on a regular basis.

        $perlmonks{seattlejohn} = 'John Clyman';

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://225407]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2023-01-27 00:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found