--> Wednesday, February 4, 2004, 5:16:43 PM, [EMAIL PROTECTED] wrote:

> I just started playing with SmartBat and I found the Evaluate
> function. So, to get a feel for things, I tried a few expressions:

> 2+4       = 6     (Okay)
> 2*4       = 8     (Looking good...)
> 5^2       = 7     (What!?! 5 squared is 25. Wait a minute. What if...)
> 1^1       = 0     (Yup! It's XORing not raising to a power.)
> 1|2       = 3     (And this is OR)
> 1|2|4     = 7     (So it this)
> 7&1       = 1     (This is AND)
> 4&1       = 0     (So it this)
> 5**2      = 25    (That's better!)
> 2*5**2    = 100   (Hunh? It should be 50.)
> 2*(5**25) = 50    (Ah! A problem with the order of operations.)
> sqrt(25)  = Error (No sqrt [square root] function? Oh well...)
> 25**.5    = 5     (I know how to get around that problem!)

> Everything seems to make sense (after I got over the binary math)
> except this:
> 2*5**2    = 100   (Hunh? It should be 50.)

> This seemed to be evaluated as:
> (2*5)**2
> (10)**2
> 100
> and not
> 2*(5**2)
> 2*(25)
> 100

> If I remember correctly, in the order of operations (PEMDAS),
> exponentiation comes after parentheses and before multiplication and
> division, which come before addition and subtraction.

> So, is this a problem with SmartBat's Evaluate function, the %CALC
> macro, the library (if any) RitLabs used to implement this
> functionality, or my memory?

I'm not sure what you're trying to do but I just started my own set
of macros today and two of the macros may interest you. One evaluates
python expressions, and the other executes python code.

So if you want to perform various math, and more, these are my results :

  2+4       : 6
  2*4       : 8
  5^2       : 7
  1^1       : 0
  1|1       : 1
  1|2|4     : 7
  7&1       : 1
  4&1       : 0
  5**2      : 0
  25        : 0
  2*5**2    : 50
  2*(5**25) : 596046447753906250L
  2*(5**2)  : 50
  25**.5    : 5.0
  
  import math
  math.sqrt(25) : 5.0
  
  address = '[EMAIL PROTECTED]'
  user,domain = address.split('@')
  
  user      : 'tb'
  domain    : 'kaishaku.org'

You can probably do just about anything you want.

-- 
[EMAIL PROTECTED] - up for: 20 day(s), 3 hour(s), 40 minute(s), 5 second(s)


________________________________________________
Current version is 2.02.3 CE | "Using TBUDL" information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to