To fix the situation where you don't know whether the
input vars are integers or decimals (such as reading
from a file, or computing a and b earlier in the script)
I thought it might work to multiply by a typed 1.0.

I discovered that it depends on where the 1.0 is placed
in the arithmetic expression.

Imagine in the following that a and b were NOT set
literally as below, so we cannot predict whether
they will be integers or decimal strings when the
script is run.

;; example A
local a = 4
local b = 3
local c = 1.0*a/b
win.debug(tostring(c)) ;; returns 1.33333
win.debug(c) ;; returns mystery stuff
quit

;; example B
local a = 4
local b = 3
local c = a/b*1.0
win.debug(tostring(c)) ;; returns 1
win.debug(c) ;; returns mystery stuff
quit

;; example C
local a = 4
local b = 3
local c = a/b
win.debug(tostring(c)) ;; returns 1
win.debug(c) ;; returns 1
quit

IMHO, examples A and C look correct
but B should work the same as A.
I guess to achieve that, the whole line would need to be
inspected to see whether it contains a decimal string
before doing the math.
What actually happens is that a/b is done the old way
(if both a and b are integers)
and "that result *0.1" is done the new way

Alternatively, Help could advise us to START each
non-integer expression with: 1.0*
when using unpredictable variables.



Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/power-pro/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to