Commits

arkdro committed d653738

change divide result comparison

Comments (0)

Files changed (1)

erlang/test/num_SUITE.erl

     false.
 
 %% this is necessary for divide only
-compare2({_S1, M1, _E1} = R1, {_S2, M2, _E2} = R2) ->
-    Dm = M1 - M2,
-    if Dm > 1 ->
-            ct:pal("compare different~n~p~n~p~n", [R1, R2]),
-            false;
-       true ->
+compare2({_S1, _M1, E1} = R1, {_S2, _M2, E2} = R2) ->
+    {_Ds, Dm, De} = decimal:subtract(R1, R2),
+    Min_exp = min(E1, E2),
+    if (Dm =< 1) and (De =< Min_exp) ->
             Verbose = ct:get_config(verbose, 0),
             if Verbose > 3 ->
                     ct:pal("compare almost equal~nr1=~p~nr2=~p~n", [R1, R2]);
                true ->
                     ok
             end,
-            true
+            true;
+       true ->
+            ct:pal("compare different~n~p~n~p~n", [R1, R2]),
+            false
     end.
 
 % -----------------------------------------------------------------------------