Loading ...
Sorry, an error occurred while loading the content.

14891Re: [Clip] isnumber function

Expand Messages
  • Don - htmlfixit.com
    Mar 9, 2006
    • 0 Attachment
      > I think the problem is with the definition of IsNumber in Help. It
      > takes an argument of "Value" and then refers to "Value" as the
      > "specified text". A better definition might be:
      > $IsNumber*("Str")$ *Returns 1 if Str contains only digits 0 through 9,
      > and 0 if it does not.
      > This explains what you observe. The fact that these numbers are
      > integers is just a coincidence. This definition also corresponds more
      > closely to the definition of IsAlpha.
      > It also might have avoided this whole thread. :-)

      Your definition would have indeed been better than the one provided ...
      but I think it is more accurate to say integers (defined as all whole
      numbers positive AND NEGATIVE and zero:
      http://en.wikipedia.org/wiki/Integer ). Your definition forgot the
      negative sign ... that is not a 0-9 character ... and can only appear
      immediately preceeding the number:
      ^!Info [C] minus 5 -- ^$IsNumber("-5")$
      ^!Info [C] 5 minus -- ^$IsNumber("5-")$
      ^!Info [C] 5 minus 5 -- ^$IsNumber("5-5")$

      This tread would have still been necessary because what I needed to do
      was test if something was a number in this format ([brackets mean
      optional] and ... ellipses means one or more):

      As isnumber didn't cover my situation ... I had to come up with a way to
      do it.

      Is is possible to test if something is a "number" with a regex?

      1. either one or no decimal point, but there can be any number of proper
      characters before and after the decimal
      2. comma's are permitted but not required, but may only be present with
      three proper characters to the right of each comma and left of the
      decimal (or implied decimal if it is an integer)
      3. proper characters are 0-9, an no other characters are permitted
      except for rule 1 (decimal point) and rule 2 (properly placed commas)

      I wrote a clip function to do it, but if there is a regex that would do
      it quicker ...

      I just did this:
      But the fact that those letters for some reason have a numeric value of
      zero when used in calculations DOES NOT make them numbers per isnumber
      when not used in calculations, as each of the following tests negative:
      ^!Info [C]abcdetxy --^$IsNumber("abcdetxy")$
      ^!Info [C]a --^$IsNumber("a")$
      ^!Info [C]aa --^$IsNumber("aa")$
      ^!Info [C]e --^$IsNumber("e")$

      But when we use calc, we are all over the place ...
      ^!Info [C]abcdetxy --^$IsNumber("^$Calc(abcdetxy)$")$
      ^!Info [C]a --^$IsNumber("^$Calc(a)$")$
      ^!Info [C]aa --^$IsNumber("^$Calc(aa)$")$
      ^!Info [C]a*a --^$IsNumber("^$Calc(a*a)$")$
      ^!Info [C]e --^$IsNumber("^$Calc(e)$")$

      Anyway, I am enjoying the tread and hope deep in my heart that this bug
      just might be the catalyst to get Eric coding either an update or better
      yet, a version 5. As I said a few months back though, I am not sure a
      version 5 is really going to happen and nobody has told me I am wrong by
      giving me any milestones, targets or goals. I'd settle for 4.96 with
      this bug fixed and isnumber better defined in help ;-)
    • Show all 22 messages in this topic