Share

Simple Rule Engine

Tracker: Bugs

5 ExpressionEvaluator treating doubles as strings - ID: 1553674
Last Update: Tracker Item Submitted ( nobody )

I'm using code to test some strings and the evaluator
is treating my Facts as strings. but i have them
declared as typeof(double). the following

F1+F2 is ouputing 100200 where it should be 300. I
think either you should check the valueType from the
symbol objects or do something like below...

double o1, o2;

object replacement;
try
{
//o1 = op1.value.Value;
//o2 = op2.value.Value;

if (double.TryParse
(op1.value.Value.ToString(), out o1) && double.TryParse
(op2.value.Value.ToString(), out o2))
{
replacement = o1 + o2;
}
else
{
replacement =
op1.value.Value.ToString() + op2.value.Value.ToString
();
}
/*if (o1 is string || o2 is string)
replacement = o1.ToString() +
o2.ToString();
else if (o1 is double && o2 is double)
replacement = (double)o1 + (double)
o2;
else
throw new Exception("only to be
caught");*/
}

basically im using the double.TryParse to convert to
strings to see if the symbol values are doubles and if
they are then adding else concating. I assume you
might want to do something like this for all the
operations.


Nobody/Anonymous ( nobody ) - 2006-09-06 21:23

5

Open

None

Nobody/Anonymous

None

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.