anchor.diff:  
   % returns: numeric
   numeric_multiply(A, B) -> 
  -   TV = fun(I) when is_integer(I) ->
  -              {'xs:integer', I};
  -           (I) when is_float(I) ->
  -              {'xs:double', I};
  -           (#xqAtomicValue{type = TypeA0, value = neg_zero}) when ?xs_numeric(TypeA0) ->
  -              {TypeA0, 0.0};
  -           (#xqAtomicValue{type = TypeA0, value = ValA0}) when ?xs_numeric(TypeA0) ->
  -              {TypeA0, ValA0};
  -           (neg_zero) ->
  -              {'xs:double', 0.0};
  -           (At) when At == nan;
  -                     At == neg_infinity;
  -                     At == infinity ->
  -              {'xs:double', At};
  -           (_) ->
  -              ?err('XPTY0004')
  -        end,
  -   {TypeA, ValA} = TV(A),
  -   {TypeB, ValB} = TV(B),
  +   {TypeA, ValA} = numeric_type_val(A),
  +   {TypeB, ValB} = numeric_type_val(B),
      
      TypeC = if TypeA =:= TypeB -> TypeA;
                 true ->
  
positive.code:    general_compare(Op,L1,L2);
  general_compare(Op,L1,{array,L2}) -> 
     general_compare(Op,L1,L2);
  general_compare(Op,#xqAtomicValue{} = List1,#xqAtomicValue{} = List2) ->
     value_compare(Op,List1,List2);
  general_compare(Op,#xqRange{} = List1,#xqAtomicValue{} = V2) ->
     Bool = range_val_comp_any(Op, List1, V2),
     ?bool(Bool);
  general_compare(Op,#xqAtomicValue{} = V1,#xqRange{} = List2) ->
     Bool = range_val_comp_any(Op, V1, List2),
     ?bool(Bool);
  general_compare(Op,#xqRange{} = List1,#xqRange{} = List2) ->
     Bool = range_range_comp_any(Op, List1, List2),
     ?bool(Bool);
     
  general_compare(Op,#xqAtomicValue{} = V1,List2) when is_list(List2) ->
     Bool = general_compare_any_2(List2, Op, V1),
     ?bool(Bool);
  general_compare(Op, V1, List2) when is_list(List2), is_boolean(V1) ->
     Bool = general_compare_any_2(List2, Op, V1),
     ?bool(Bool);
  general_compare(Op,List1,#xqAtomicValue{} = V2) when is_list(List1) ->
     Bool = general_compare_any_1(List1, Op, V2),
     ?bool(Bool);
  general_compare(Op, List1, V2) when is_list(List1), is_boolean(V2) ->
     Bool = general_compare_any_1(List1, Op, V2),
     ?bool(Bool);
  general_compare(Op, V1, V2) when is_boolean(V1), is_boolean(V2) ->
     value_compare(Op, V1, V2);
  
  general_compare(Op, V1, #{nk := _} = V2) ->
     general_compare(Op, V1, xqerl_types:atomize(V2));
  
negative.code: 
  % returns: numeric
  numeric_subtract(A, B) ->
     {TypeA, ValA} = numeric_type_val(A),
     {TypeB, ValB} = numeric_type_val(B),
     TypeC = if TypeA =:= TypeB -> TypeA;
                true ->
                   get_numeric_type(TypeA, TypeB)
  