Skip to content

Commit

Permalink
updating math nodes to fit the new paradigm (maybe it fixes this nast…
Browse files Browse the repository at this point in the history
…y suprising bug???)
  • Loading branch information
EarliestFall988 committed Dec 11, 2023
1 parent 285ca2b commit af78b12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
19 changes: 7 additions & 12 deletions State Machine/Function Definitions/Math/MultiplyNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,19 @@ protected override void DefineFunction()
Name = nameof(MultiplyNumber);
Function = () =>
{
var x = Parameters["a"];
var y = Parameters["b"];

var z = Parameters["out"];

if (x is VariableDefinition<decimal> aV && y is VariableDefinition<decimal> bV && z is VariableDefinition<decimal> resultV)
{
var b = bV.Value;
var a = aV.Value;
var a = Get<float>("a");
var b = Get<float>("b");

Debug.WriteLine($"{a} * {b} = {a * b}");
var result = a * b;

resultV.Value = a * b;
Debug.WriteLine("a: " + a + " b: " + b + " result: " + result);

return 1;
}
Set<float>("out", result);

return -1;

return 1;
};
}
}
Expand Down
21 changes: 6 additions & 15 deletions State Machine/Function Definitions/Math/Pow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,17 @@ protected override void DefineFunction()
Name = nameof(PowNumber);
Function = () =>
{
var x = Parameters["a"];
var y = Parameters["b"];
var a = Get<float>("a");
var b = Get<float>("b");

var z = Parameters["out"];

if (x is VariableDefinition<decimal> aV && y is VariableDefinition<decimal> bV && z is VariableDefinition<decimal> resultV)
{
var result = (float)Math.Pow(a, b);

var b = bV.Value;
var a = aV.Value;
Debug.WriteLine("a: " + a + " b: " + b + " result: " + result);

var powResult = Math.Pow((double)a, (double)b);
Set<float>("out", result);

Debug.WriteLine($"{a} to the power of {b} = {powResult}");

resultV.Value = (decimal)powResult;
return 1;
}

return -1;
return 1;

};
}
Expand Down

0 comments on commit af78b12

Please sign in to comment.