How to force  powerpro to evaluate an arbitrary, apriori unknown numerical 
expression using floating 
point math?

If one of the operands is a fp number powerpro will use fp math, but since the 
expression is unknown 
beforehand, you can't tell whether it includes a fp number.

For instance, if string p contains the expression to be evaluated, and it is p 
= "3300/1200"
then eval(p) is 1, but if p = "3300.0/1200"
then ftos(eval(p)) is 1.375

How to ensure that for any expression you get the second result, the fp math 
result?

I came out with a solution, which is to use a regex replacement to stick a ".0" 
after the first integer (if any) 
found in the expression. It seems to work, but it also seems more complicated 
than it should be. Isn't there 
a simpler solution that I overlooked?
;
p = "3300/2400"
win.debug(eval(p))
p = regex.pcrereplace(?"^(.*?)(?<![.,\d])(\d+)\b(?![.,])(.*?)$",p,?"$1$2.0$3")
win.debug(ftos(eval(p)))

Reply via email to