in reply to Re: Testing For Numberness Vs Stringness
in thread Testing For Numberness Vs Stringness

Hi Dave, thanks for your reply.

I understand that this is what perl does. I fear this is very broken. I'm writing a test harness that needs to validate results of other routines. Since numbers and strings respond differently when compared by == and eq, the harness needs to be able to distinguish numbers from strings.

  • Comment on Re^2: Testing For Numberness Vs Stringness

Replies are listed 'Best First'.
Re^3: Testing For Numberness Vs Stringness
by theorbtwo (Prior) on Nov 27, 2004 at 23:24 UTC

    Have sepperate functions for numeric vs stringy tests, then. The answer to "is 03 the same as 3" depends on intentions, and not any occult flags of the 3.0 and the 3 that your program could concivably read.

      When a test routine is recursing its way, scalar by scalar, through a possibly unknown data structure -- such as during a deep compare -- it can't decide whether to use a numeric vs stringy test. There are no "intentions" to know, and no metastructure (occult or not) to consult. Fortunately, as bgreenlea showed in his or her reply, no "occult flags" are needed -- the bit-by-bit comparison does the trick.