Commits

arkdro committed 00c2984

add compare2 to compare div results

  • Participants
  • Parent commits 019707e

Comments (0)

Files changed (1)

File erlang/test/num_SUITE.erl

     end,
     true;
 compare({ok, R1}, R2) ->
-    Cmp_res_s = decimal:compare(R1, R2, ?d_context_short),
     case decimal:compare(R1, R2, ?d_context) of
         0 ->
             Verbose = ct:get_config(verbose, 0),
                     ok
             end,
             true;
-        _ when Cmp_res_s == 0 ->
+        _ ->
+            compare2(R1, R2)
+    end;
+compare(R1, R2) ->
+    ct:pal("compare different, not even close~n~p~n~p~n", [R1, R2]),
+    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 ->
             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;
-        _ ->
-            ct:pal("compare not equal~n~p~n~p~n", [R1, R2]),
-            false
-    end;
-compare(R1, R2) ->
-    ct:pal("compare different, not even close~n~p~n~p~n", [R1, R2]),
-    false.
+            true
+    end.
 
 % -----------------------------------------------------------------------------
 % Function: TestCase(Config0) ->