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

Re: [Clip] isnumber function

Expand Messages
  • loro
    ... Oh. Clear as mud! Thank you. ... You are right. How strange. Bet there is a logical explanation as usual but I can t guess what it is. ln() seems to work
    Message 1 of 22 , Mar 4, 2006
    • 0 Attachment
      Don wrote:
      > I call anything that is a number a number in English. That
      >function should say tells you if it is an integer number ....

      Oh. Clear as mud! Thank you.

      >Another bug: multiply x*1=0
      >Why would that be? The result is that because 0 is an integer ... x is
      >a number if you use your calculation method! It doesn't have to be an x
      >either, I tried a c and same result ...

      You are right. How strange. Bet there is a logical explanation as usual but
      I can't guess what it is.

      ln() seems to work more as expected than multiplication. If I add that it
      seems to work correctly.

      ^!If ^$IsNumber("^$Calc(ln(^$GetSelection$)*1;0)$")$ = 1 num else notnum

      Lotta
    • loro
      Don, It isn t only multiplication. A single letter a-z always is 0. Anyone knows why this is? a+1=1 a*1=0 a/1=0 a^1=0 1^a=1 a*a=0 For example these return an
      Message 2 of 22 , Mar 4, 2006
      • 0 Attachment
        Don,
        It isn't only multiplication. A single letter a-z always is 0. Anyone
        knows why this is?

        a+1=1
        a*1=0
        a/1=0
        a^1=0
        1^a=1
        a*a=0

        For example these return an error, same as they do if 0 is used instead of a.
        1/a=[error]
        ln(a)=[error]

        So this would work too.
        ^!If ^$IsNumber("^$Calc(1/^$GetSelection$;0)$")$ = 1 num else notnum

        Now the question is - why is it this way?

        Lotta
      • John Wallace
        I don t have any knowledge on this, just thinking out loud. I would say the a is interpeted as not numeric and given a binary value of zero. Possibly the
        Message 3 of 22 , Mar 4, 2006
        • 0 Attachment
          I don't have any knowledge on this, just thinking out loud.

          I would say the 'a' is interpeted as not numeric and given a binary value of zero.
          Possibly the letter 'a' needs a declaration to show it's a variable instead of a letter?




          John Wallace
          Pontiac Power RULES !!!
          www.wallaceracing.com

          Subject: Re: [Clip] isnumber function - calculating with letters

          Don,
          It isn't only multiplication. A single letter a-z always is 0. Anyone knows why this is?

          a+1=1
          a*1=0
          a/1=0
          a^1=0
          1^a=1
          a*a=0

          For example these return an error, same as they do if 0 is used instead of a.
          1/a=[error]
          ln(a)=[error]

          So this would work too.
          ^!If ^$IsNumber("^$Calc(1/^$GetSelection$;0)$")$ = 1 num else notnum

          Now the question is - why is it this way?

          Lotta
        • Don - HtmlFixIt.com
          ... Hi Lotta, The above fails on this example: 1,00,00.10 Well I guess we could argue that is a number (begging that question again I suppose). At best, I
          Message 4 of 22 , Mar 4, 2006
          • 0 Attachment
            > ln() seems to work more as expected than multiplication. If I add that it
            > seems to work correctly.
            >
            > ^!If ^$IsNumber("^$Calc(ln(^$GetSelection$)*1;0)$")$ = 1 num else notnum

            Hi Lotta,

            The above fails on this example: "1,00,00.10"
            Well I guess we could argue that is a number (begging that question
            again I suppose). At best, I would suggest that it is a mis-formed
            number. I don't know if I would have cared ... but for trying a bunch
            of things it may not have occurred to me to check such a thing.

            What happens if you divide by a letter ... is that division by zero? :-)

            By the way using this method, "1.10.10", is not a number, so I think
            that more than one period/decimal/fullstop is bad, but placement of
            commas is apparently ignored.

            In an effort to test that theory I then used this: "1,,,,,,,,,,,1".
            Good news! It is a number ;-)

            Thanks to all who contributed.

            BTW here is a post from Alan that got lost in cyberspace somewhere:


            Hi Don,

            I'm wonder if the period and the comma happen to also fit within the
            other, the corresponding (what is it, the getascii function or is it
            IsAscii function)

            (there are two functions of which that each does what the other doesn't,
            IsNumber is one of these two)

            IOW the conterpart to IsNumber

            period and comma be found in "not number" (in sentences) too.

            But, yes, given sufficient parsing ability/intelligence, I agree with
            you on integers versus decimals.

            I suppose in the meantime, may need to pre parse, rounding off to rid of
            period and eliminate commas if they exist.

            Alan.
          • loro
            ... Come on! That isn t a (correctly written) number any way you see it. A writing convention maybe, but would you write it like that using a calculator? We
            Message 5 of 22 , Mar 4, 2006
            • 0 Attachment
              Don wrote:
              >The above fails on this example: "1,00,00.10"

              Come on! That isn't a (correctly written) number any way you see it. A
              writing convention maybe, but would you write it like that using a
              calculator? We use to write "money" like this: "10:95" (where you would
              write 10.95). That doesn't work either. :-)

              Lotta
            • Don - HtmlFixIt.com
              ... I think we agree then :-) I probably didn t mean what I said or say what I meant. By fails I meant that it shows it to be a number when I would argue it
              Message 6 of 22 , Mar 4, 2006
              • 0 Attachment
                loro wrote:
                > Don wrote:
                >> The above fails on this example: "1,00,00.10"
                >
                > Come on! That isn't a (correctly written) number any way you see it. A
                > writing convention maybe, but would you write it like that using a
                > calculator? We use to write "money" like this: "10:95" (where you would
                > write 10.95). That doesn't work either. :-)
                >
                > Lotta
                >
                I think we agree then :-)

                I probably didn't mean what I said or say what I meant. By fails I
                meant that it shows it to be a number when I would argue it "isn't" a
                number. I would have wanted it to say "not a number" but is said "is a
                number" when I put it to the ln() test. So I would argue while better
                than without that method that the method did not work to find well
                formed numbers. We would also agree I think that 1,,,,,,1 isn't a
                number, but that method found it to be one.

                I am actually working on a European clip, so I have converted commas to
                decimals so they are in my way of thinking before I test them. There
                they say 10,95 vs my 10.95 vs your (now outdated) 10:95. I used
                strreplace to convert it to my "proper" number formula. Then I wanted
                to test it to be sure it was good.
              • loro
                ... My Notetab handles comma as well as period as decimal point. I don t know if that is programmed in Notatab or if it in some way pick the comma up from my
                Message 7 of 22 , Mar 5, 2006
                • 0 Attachment
                  Don:
                  >I am actually working on a European clip, so I have converted commas to
                  >decimals so they are in my way of thinking before I test them. There
                  >they say 10,95 vs my 10.95 vs your (now outdated) 10:95. I used
                  >strreplace to convert it to my "proper" number formula. Then I wanted
                  >to test it to be sure it was good.

                  "My" Notetab handles comma as well as period as decimal point. I don't know
                  if that is programmed in Notatab or if it in some way pick the comma up
                  from my system. I have some other (not swedish) programs that demand that I
                  use comma, just because of my locale. Very irritating. I'm now used to
                  period, so I get it wrong all the time.

                  But I meant numbers like this one: 1,00,00.10. As I see it there are two
                  too many, either you use comma or period. ;-)

                  It's odd though. I also feel that what's not numeric should be alpha. And
                  did we figure out why letters, mathematically, are zero? ;-o)

                  Lotta
                • Larry Hamilton
                  ... Lotta, The IsNumber function is a True/False test. Either the selected information is a number or it is not. The Clip Help indicates that it returns 1 for
                  Message 8 of 22 , Mar 8, 2006
                  • 0 Attachment
                    loro wrote:
                    > It's odd though. I also feel that what's not numeric should be alpha. And
                    > did we figure out why letters, mathematically, are zero? ;-o)
                    >
                    > Lotta
                    Lotta,

                    The IsNumber function is a True/False test. Either the selected
                    information is a number or it is not. The Clip Help indicates that it
                    returns 1 for a number and 0 if it is not. It must assume decimal
                    numbers, there is no option to consider Hexadecimal. But octal and
                    binary values that have the same characters to represent decimal numbers
                    would evaluate to numbers, if there is no character as part of the
                    number indicating something other than decimal.

                    I have not tested region-specific delimiters for thousands and decimals,
                    but it should rely on the regional settings to determine if certain
                    values are numbers or not. If it does not fit the pattern for thousands
                    and decimals, then it must be a problem with the infamous input control.

                    Larry Hamilton
                    Kairos Computer Solutions
                    http://www.kairoscomputers.com/
                    Sales Affiliate for Grisoft Anti-Virus
                  • Don - htmlfixit.com
                    ... Hi Larry, Of the things we tested only the following were numbers (according to isnumber): a. an integer b. any single letter of the alphabet (I consider
                    Message 9 of 22 , Mar 8, 2006
                    • 0 Attachment
                      Larry Hamilton wrote:
                      > loro wrote:
                      >
                      >>It's odd though. I also feel that what's not numeric should be alpha. And
                      >>did we figure out why letters, mathematically, are zero? ;-o)
                      >>
                      >>Lotta
                      >
                      > Lotta,
                      >
                      > The IsNumber function is a True/False test. Either the selected
                      > information is a number or it is not. The Clip Help indicates that it
                      > returns 1 for a number and 0 if it is not. It must assume decimal
                      > numbers, there is no option to consider Hexadecimal. But octal and

                      Hi Larry,

                      Of the things we tested only the following were numbers (according to
                      isnumber):
                      a. an integer
                      b. any single letter of the alphabet (I consider this to be a bug)

                      The following were not numbers:
                      a. any decimal number
                      b. any mixed characters other than a single alphabetic character
                      c. any number with commas in it for example 1,000

                      So isnumber isn't isnumber, it is isinteger (with an odd twist of single
                      alphabetic characters tossed in).

                      Hopefully this can be fixed in version 4.96.
                    • loro
                      ... Except if it s a single letter! :-) ... It works, as I can use both period and comma. The problem is that a single alphabetic character returns true when
                      Message 10 of 22 , Mar 8, 2006
                      • 0 Attachment
                        Larry Hamilton wrote:
                        >The IsNumber function is a True/False test. Either the selected
                        >information is a number or it is not.

                        Except if it's a single letter! :-)

                        >I have not tested region-specific delimiters for thousands and decimals,
                        >but it should rely on the regional settings to determine if certain
                        >values are numbers or not. If it does not fit the pattern for thousands
                        >and decimals, then it must be a problem with the infamous input control.

                        It works, as I can use both period and comma.

                        The problem is that a single alphabetic character returns true when tested
                        with $IsNumber$, as Don discovered. What more is, the letter seems to
                        evaluate to 0. Or that's what we thought yesterday. But I tried to
                        calculate with all the letters in the alphabet and it turns out this only
                        "works" with the letters a, b, c, d, e, t, x and y. The others return an
                        error, as we expected they all would ("expression could not be evaluated").
                        But it doesn't stop here. Take a look at this. Just calculate with Ctrl+E,
                        no clip needed.

                        a*2=0
                        b*2=0
                        c*2=0
                        d*2=0
                        e*2=0
                        t*2=0
                        x*2=0
                        y*2=0

                        2^a=1
                        2^b=1
                        2^c=1
                        2^d=1
                        2^e=1
                        2^t=1
                        2^x=1
                        2^y=1

                        The letters act as they were zero. But look what happens with e here...


                        a+2=2
                        b+2=2
                        c+2=2
                        d+2=2
                        e+2=0
                        t+2=2
                        x+2=2
                        y+2=2

                        a-2=-2
                        b-2=-2
                        c-2=-2
                        d-2=-2
                        e-2=0
                        t-2=-2
                        x-2=-2
                        y-2=-2


                        ??????????????
                        Lotta
                      • Don - htmlfixit.com
                        As we all know, the letter e is the most popular letter, so it demands to be treated differently during negotiations, don t you think?
                        Message 11 of 22 , Mar 8, 2006
                        • 0 Attachment
                          As we all know, the letter e is the most popular letter, so it demands
                          to be treated differently during negotiations, don't you think?

                          > The letters act as they were zero. But look what happens with e here...
                          >
                          >
                          > a+2=2
                          > b+2=2
                          > c+2=2
                          > d+2=2
                          > e+2=0
                          > t+2=2
                          > x+2=2
                          > y+2=2
                          >
                          > a-2=-2
                          > b-2=-2
                          > c-2=-2
                          > d-2=-2
                          > e-2=0
                          > t-2=-2
                          > x-2=-2
                          > y-2=-2
                        • loro
                          ... I think it s nothing less than an insult that I can t calculate with å, ä and ö, that s what I think. I ll probably write to Jody about this. I demand
                          Message 12 of 22 , Mar 8, 2006
                          • 0 Attachment
                            Don wrote:
                            >As we all know, the letter e is the most popular letter, so it demands
                            >to be treated differently during negotiations, don't you think?

                            I think it's nothing less than an insult that I can't calculate with å, ä
                            and ö, that's what I think. I'll probably write to Jody about this. I
                            demand that åäö calculation will be properly implemented in the next version!

                            Lotta - who is joking (better add that! ;-o))
                          • Larry Hamilton
                            ... I d like to buy a Q. ;-) I do not know if this behavior for IsNumber is a clip language bug or a problem with the infamous input control. I do not need
                            Message 13 of 22 , Mar 8, 2006
                            • 0 Attachment
                              Don - htmlfixit.com wrote:
                              > As we all know, the letter e is the most popular letter, so it demands
                              > to be treated differently during negotiations, don't you think?
                              I'd like to buy a Q. ;-)

                              I do not know if this behavior for IsNumber is a clip language bug or a
                              problem with the infamous input control. I do not need this function too
                              often, so personally not a big problem, but it should be fixed.

                              Larry
                            • Bill Newman
                              ... 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
                              Message 14 of 22 , Mar 8, 2006
                              • 0 Attachment
                                Don - htmlfixit.com wrote:

                                > Larry Hamilton wrote:
                                > > loro wrote:
                                > >
                                > >>It's odd though. I also feel that what's not numeric should be
                                > alpha. And
                                > >>did we figure out why letters, mathematically, are zero? ;-o)
                                > >>
                                > >>Lotta
                                > >
                                > > Lotta,
                                > >
                                > > The IsNumber function is a True/False test. Either the selected
                                > > information is a number or it is not. The Clip Help indicates that it
                                > > returns 1 for a number and 0 if it is not. It must assume decimal
                                > > numbers, there is no option to consider Hexadecimal. But octal and
                                >
                                > Hi Larry,
                                >
                                > Of the things we tested only the following were numbers (according to
                                > isnumber):
                                > a. an integer
                                > b. any single letter of the alphabet (I consider this to be a bug)
                                >
                                > The following were not numbers:
                                > a. any decimal number
                                > b. any mixed characters other than a single alphabetic character
                                > c. any number with commas in it for example 1,000
                                >
                                > So isnumber isn't isnumber, it is isinteger (with an odd twist of single
                                > alphabetic characters tossed in).

                                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. :-)

                                > Hopefully this can be fixed in version 4.96.
                                >
                                >
                                > Fookes Software: http://www.fookes.us, http://www.fookes.com
                                > Fookes Software Mailing Lists: http://www.fookes.us/maillist.htm
                              • Don - htmlfixit.com
                                ... 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
                                Message 15 of 22 , 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?

                                  Rules:
                                  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:
                                  a+b+c+d+e+t+x+y=0
                                  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 ;-)
                                • Hugo Paulissen
                                  Don, You could try this... It fetches 4.96 as well as 5.0. And: 123,4234,976.345 4234,976.345 234,976.345 4234976.345 4234976345 1 ( d+,)* d+( .)* d* Hugo
                                  Message 16 of 22 , Mar 9, 2006
                                  • 0 Attachment
                                    Don,

                                    You could try this...

                                    It fetches 4.96 as well as 5.0.

                                    And:
                                    123,4234,976.345
                                    4234,976.345
                                    234,976.345
                                    4234976.345
                                    4234976345
                                    1

                                    (\d+,)*\d+(\.)*\d*

                                    Hugo
                                  • Jody
                                    Hi Lotta and All, ... LOL! Actually, I have been trying to follow this thread, but my time is limited. I have sent posts to me to file it as a bug. I m sure
                                    Message 17 of 22 , Mar 9, 2006
                                    • 0 Attachment
                                      Hi Lotta and All,

                                      >Don wrote:
                                      >> As we all know, the letter e is the most popular letter, so it
                                      >> demands to be treated differently during negotiations, don't
                                      >> you think?
                                      >
                                      >I think it's nothing less than an insult that I can't calculate
                                      >with å, ä and ö, that's what I think. I'll probably write to Jody
                                      >about this. I demand that åäö calculation will be properly
                                      >implemented in the next version!

                                      LOL! Actually, I have been trying to follow this thread, but my
                                      time is limited. I have sent posts to me to file it as a bug. I'm
                                      sure Eric will take it into consideration in the infamous
                                      4.96/5.0/6.0 release. I'll push to get the extended characters
                                      added along with giving "e" preference Don, but only after "E". :)

                                      >Lotta - who is joking (better add that! ;-o))


                                      Happy Topics,
                                      Jody

                                      The NoteTab Off-Topic List
                                      mailto:ntb-OffTopic-Subscribe@yahoogroups.com
                                      mailto:ntb-OffTopic-UnSubscribe@yahoogroups.com

                                      All Fookes Software mailing lists and more...
                                      http://www.fookes.us/maillist.htm
                                      http://www.fookes.us/redir http://www.clean-funnies.com/
                                      http://www.notetab.net/ http://www.sojourner.us/software
                                    • Charles M. Raine
                                      Hi Don: ... Not quite correct Don as not all of your Calc statements are valid. Try the following to see what I mean. ^!Info [C]abcdetxy --
                                      Message 18 of 22 , Mar 9, 2006
                                      • 0 Attachment
                                        Hi Don:

                                        On Thu, 09 Mar 2006 08:46:18 -0500, Don - htmlfixit.com wrote:
                                        > 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)$")$

                                        Not quite correct Don as not all of your Calc statements are valid. Try the

                                        following to see what I mean.

                                        ^!Info [C]abcdetxy -- ^$IsNumber("^$Calc(abcdetxy+0)$")$ --
                                        ^$Calc(abcdetxy+0)$
                                        ^!Info [C]a -- ^$IsNumber("^$Calc(a+0)$")$ -- ^$Calc(a+0)$
                                        ^!Info [C]aa -- ^$IsNumber("^$Calc(a+a)$")$ -- ^$Calc(a+a)$
                                        ^!Info [C]a*a -- ^$IsNumber("^$Calc(a*a)$")$ -- ^$Calc(a*a)$
                                        ^!Info [C]e -- ^$IsNumber("^$Calc(e+0)$")$ -- ^$Calc(e+0)$

                                        Charlie
                                        Charles M. Raine,
                                        Winnipeg. MB R3P 0W3
                                      Your message has been successfully submitted and would be delivered to recipients shortly.