diff --git a/lib/src/defs.dart b/lib/src/defs.dart index 19ecba6..32f127b 100644 --- a/lib/src/defs.dart +++ b/lib/src/defs.dart @@ -3,7 +3,7 @@ part of function_tree; /// A mapping of string representations to two-parameter functions. final Map _twoParameterFunctionMap = { 'log': (num b, num x) => log(x) / log(b), - 'nrt': (num n, num x) => pow(x, 1 / n), + 'nrt': (num n, num x) => (x.isNegative && n.toInt().isOdd ? -1:1)* pow(n.toInt().isOdd ? x.abs() : x, 1 / n), 'pow': (num x, num p) => pow(x, p) }; diff --git a/test/two-parameter-functions.dart b/test/two-parameter-functions.dart index 8013157..386c499 100644 --- a/test/two-parameter-functions.dart +++ b/test/two-parameter-functions.dart @@ -12,4 +12,7 @@ void main() { final h = 'nrt(3, 27)'.interpret(); print(h); + + final i = 'nrt(3, -3)'.interpret(); + print(i); }