Do not use WolframAlpha to verify floating-point arithmetic results. Use Dart itself or any other programming language (Python, JavaScript, etc.). For example, your solution (where I replaced Frac with double everywhere) fails the following test:
It seems like you compute it as (9/7) * (3/5) which is not correct since * and / have the same precedence. So it should be computed as ((9/7) * 3) / 5.
I admit that the kata description is not precise. I plan to update it at some point to make it clear how all expressions should be evaluated. It is also important to specify that all intermediate results should be computed with double precision.
There are no issues with Dart tests. Use double everywhere and make sure that you evaluate all operations from left to right if they have the same precedence. Floating-point arithmetic is not random. You always get the same result if you perform all operations in the correct order.
Are you sure about this statement?
Do not use WolframAlpha to verify floating-point arithmetic results. Use Dart itself or any other programming language (Python, JavaScript, etc.). For example, your solution (where I replaced
Frac
withdouble
everywhere) fails the following test:Let's verify the expected result with Dart itself:
The result is
expr = 64.69433890577507
.Here is a small example for which your solution returns a wrong result:
It seems like you compute it as
(9/7) * (3/5)
which is not correct since*
and/
have the same precedence. So it should be computed as((9/7) * 3) / 5
.I admit that the kata description is not precise. I plan to update it at some point to make it clear how all expressions should be evaluated. It is also important to specify that all intermediate results should be computed with
double
precision.There are no issues with Dart tests. Use
double
everywhere and make sure that you evaluate all operations from left to right if they have the same precedence. Floating-point arithmetic is not random. You always get the same result if you perform all operations in the correct order.This comment is hidden because it contains spoiler information about the solution
Thanks a lot, this issue was not only in dart but in all languages :)