diff --git a/src/operators.c b/src/operators.c
index 9bb45e71ad021029a18f41e9157fb4f7d392796f..2ada04e362f72bb005c24d89e7acd43383fbf1fd 100644
--- a/src/operators.c
+++ b/src/operators.c
@@ -6,7 +6,7 @@
 /**/
 #include "global.h"
 #include <math.h>
-RCSID("$Id: operators.c,v 1.73 1999/12/13 19:58:44 grubba Exp $");
+RCSID("$Id: operators.c,v 1.74 1999/12/13 20:18:00 grubba Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "multiset.h"
@@ -1110,20 +1110,20 @@ void o_xor(void)
 
   case T_TYPE:
   {
-    /* a ^ b  ==  (a&!b)|(!a&b) */
+    /* a ^ b  ==  (a&~b)|(~a&b) */
     struct pike_string *a;
     struct pike_string *b;
     copy_shared_string(a, sp[-2].u.string);
     copy_shared_string(b, sp[-1].u.string);
-    o_not();		/* !b */
-    o_and();		/* a&!b */
+    o_compl();		/* ~b */
+    o_and();		/* a&~b */
     push_string(a);
     sp[-1].type = T_TYPE;
-    o_not();		/* !a */
+    o_compl();		/* ~a */
     push_string(b);
     sp[-1].type = T_TYPE;
-    o_and();		/* !a&b */
-    o_or();		/* (a&!b)|(!a&b) */
+    o_and();		/* ~a&b */
+    o_or();		/* (a&~b)|(~a&b) */
     return;
   }
 
@@ -1826,15 +1826,6 @@ void o_not(void)
     }
     break;
 
-  case T_TYPE:
-    type_stack_mark();
-    push_unfinished_type(sp[-1].u.string);
-    push_type(T_NOT);
-    pop_stack();
-    push_string(pop_unfinished_type());
-    sp[-1].type = T_TYPE;
-    break;
-
   default:
     free_svalue(sp-1);
     sp[-1].type=T_INT;
@@ -1878,6 +1869,15 @@ void o_compl(void)
     sp[-1].u.float_number = -1.0 - sp[-1].u.float_number;
     break;
 
+  case T_TYPE:
+    type_stack_mark();
+    push_unfinished_type(sp[-1].u.string);
+    push_type(T_NOT);
+    pop_stack();
+    push_string(pop_unfinished_type());
+    sp[-1].type = T_TYPE;
+    break;
+
   case T_STRING:
   {
     struct pike_string *s;
@@ -2212,7 +2212,8 @@ void init_operators(void)
   /* function(mixed...:int) */
   ADD_EFUN2("`!=",f_ne,tFuncV(tNone,tMix,tInt01),OPT_TRY_OPTIMIZE,0,generate_comparison);
   /* function(mixed:int) */
-  add_efun2("`!",f_not,"function(!type:int(0..1))|function(type:type)",OPT_TRY_OPTIMIZE,optimize_not,generate_not);
+  add_efun2("`!",f_not,"function(mixed:int(0..1))",OPT_TRY_OPTIMIZE,
+	    optimize_not,generate_not);
 
 #define CMP_TYPE "!function(!(object|mixed)...:mixed)&function(mixed...:int(0..1))|function(int|float...:int(0..1))|function(string...:int(0..1))|function(type,type,type...:int(0..1))"
   add_efun2("`<", f_lt,CMP_TYPE,OPT_TRY_OPTIMIZE,0,generate_comparison);
@@ -2298,7 +2299,13 @@ void init_operators(void)
 	    OPT_TRY_OPTIMIZE,0,generate_mod);
 
   /* function(object:mixed)|function(int:int)|function(float:float)|function(string:string) */
-  ADD_EFUN2("`~",f_compl,tOr4(tFunc(tObj,tMix),tFunc(tInt,tInt),tFunc(tFlt,tFlt),tFunc(tStr,tStr)),OPT_TRY_OPTIMIZE,0,generate_compl);
+  ADD_EFUN2("`~",f_compl,
+	    tOr5(tFunc(tObj,tMix),
+		 tFunc(tInt,tInt),
+		 tFunc(tFlt,tFlt),
+		 tFunc(tStr,tStr),
+		 tFunc(tType,tType)),
+	    OPT_TRY_OPTIMIZE,0,generate_compl);
   /* function(string|multiset|array|mapping|object:int) */
   ADD_EFUN2("sizeof", f_sizeof,tFunc(tOr5(tStr,tMultiset,tArray,tMapping,tObj),tInt),0,0,generate_sizeof);