[OT] -10^2

Klaus Major klaus at major-k.de
Thu May 22 12:15:00 EDT 2003


Hi folks,

>> Hope I don't get flamed for this, but I don't agree.
>> :-)  Someone feel free to dispute me if I'm wrong, but
>> I think Rev is correct. Isn't -10^2 the same as -10*-10
>
> Totally agree with you...
> I read -10^2 as (-10)^2 not -(10^2)
>
> As the interpretation seems to be in the eye of the beholder, then to 
> save
> creating any doubt I'd always recommend parenthesis.
>
> Gary Rathbone BSc MBCS

sorry, this is a lenghty but necessary post ;-)

This is from the MC help file and help understand what RR is doing here:
(...and is a good info anyway ;-)

> Operators:
>
> Order 1:
>   ()            # groups an expression
>
> Order 2:
>   -             # unary minus (e.g., -4)

!!!

Yes, i also was a bit surprised by that...

This operator comes BEFORE...

>   not           # make the opposite of a boolean
>   bitNot        # bitwise negation
>   there is      # check existence of an object
>
> Order 3:
>   ^             # raise a number to a power

...this one, which should explain RRs behaviour...

> Order 4:
>   *             # multiply two numbers
>   /             # divide one number by another
>   div           # integer divide (no fractional part)
>   mod           # remainder after a div
>
> Order 5:
>   +             # add two numbers
>   -             # subtract two numbers
>
> Order 6:
>   &             # concatenates two strings
>   &&            # concats, but inserts a space
>   ,             # concats, but inserts a comma
>
> Order 7:       compares numbers or strings (boolean)
>   <             # less than
>   <=            # less than or equal to
>   >             # greater than
>   >=            # greater than or equal to
>   contains      # first string contains second
>   is among      # first string is a whole chunk in second
>   is not among  # first string is not a whole chunk in second
>   is in         # first string is a substring of second
>   is not in     # 1st string is not a substring of 2nd
>   is within     # point is in a rectangle
>   is not within # point is not in a rectangle
>   is a(n)       # type check
>   is not a(n)   # type check
>
> Order 8:       compares numbers or strings (boolean)
>   =             # equal
>   <>            # not equal
>   is            # equal
>   is not        # not equal
>
> Order 9:
>   bitAnd        # bitwise and
>
> Order 10:
>   bitXor        # bitwise exclusive or
>
> Order 11:
>   bitOr         # bitwise or
>
> Order 12:
>   and           # compare boolean expressions
>
> Order 13:
>   or            # compare boolean expressions
>
> The boolean operators return either true or false and can be used as 
> the condition of an if construct.  The bitwise operators can only be 
> used on numbers, and operate directly on the binary representation of 
> the numbers.
>
> The validation operator "there" is used to verify that an object 
> exists before trying to access it.  You can use it with any object 
> type (background, button, card, field, group, image, scrollbar, stack) 
> or the word "file", "directory", or "process".  For example, to 
> prevent errors when a user clicks on a term that does not have a card 
> describing it, the following statements are used in a mouseUp handler 
> in this stack:
>
> if there is a card the clickText
> then go to card the clickText
>
> The sense of the "there" operator can be reversed with the word "no" 
> as in:
>
> there is no file "myfile.txt"
>
> The is operator can be used to compare strings or numbers, as strings 
> or numbers, but also to determine if the source is a complete chunk 
> (word, item, or line) within the destination.  This use is similar to 
> the contains operator, and the itemOffset, lineOffset, and wordOffset 
> functions when the wholeMatches property is set to true:
> put "3" is among the items of "22,33,44" #returns false
> put "3" is among the words of "2 3 4"    #returns true
>
> The is operator can also be used as a validation operator:
>
> if field "size" is a number
> then add 10 to field "size"
>
> The types that can be verified are date, number, integer, point, rect, 
> and boolean.

Hope that helps...


Regards

Klaus Major
klaus at major-k.de




More information about the use-livecode mailing list