Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.143
diff -u -r1.143 tclExecute.c
--- generic/tclExecute.c	8 Jun 2004 19:27:01 -0000	1.143
+++ generic/tclExecute.c	2 Jul 2004 21:50:45 -0000
@@ -5857,8 +5857,7 @@
     ClientData clientData;	/* Ignored. */
 {
     Tcl_Obj *valuePtr;
-    long iResult;
-    double d, temp;
+    double d;
 
     /*
      * Pop the argument from the evaluation stack.
@@ -5870,51 +5869,43 @@
 	return TCL_ERROR;
     }
     
-    if (valuePtr->typePtr == &tclIntType) {
-	iResult = valuePtr->internalRep.longValue;
-    } else if (valuePtr->typePtr == &tclWideIntType) {
-	Tcl_WideInt w;
-	TclGetWide(w,valuePtr);
-	PUSH_OBJECT(Tcl_NewWideIntObj(w));
-	goto done;
+    if ((valuePtr->typePtr == &tclIntType) ||
+	    (valuePtr->typePtr == &tclWideIntType)) {
+	PUSH_OBJECT(valuePtr);
     } else {
 	d = valuePtr->internalRep.doubleValue;
 	if (d < 0.0) {
 	    if (d <= (((double) (long) LONG_MIN) - 0.5)) {
-		tooLarge:
-		Tcl_ResetResult(interp);
-		Tcl_AppendToObj(Tcl_GetObjResult(interp),
-		        "integer value too large to represent", -1);
-		Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW",
-			"integer value too large to represent",
-			(char *) NULL);
-		return TCL_ERROR;
-	    }
-	    temp = (long) (d - 0.5);
+		if (d <= Tcl_WideAsDouble(LLONG_MIN)-0.5) {
+		    tooLarge:
+		    Tcl_ResetResult(interp);
+		    Tcl_AppendToObj(Tcl_GetObjResult(interp),
+			    "integer value too large to represent", -1);
+		    Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW",
+			    "integer value too large to represent",
+			    (char *) NULL);
+		    return TCL_ERROR;
+		}
+		PUSH_OBJECT(Tcl_NewWideIntObj(Tcl_DoubleAsWide(d - 0.5)));
+	    } else {
+		PUSH_OBJECT(Tcl_NewLongObj((long) (d - 0.5)));
+	    }			    
 	} else {
 	    if (d >= (((double) LONG_MAX + 0.5))) {
-		goto tooLarge;
+		if (d >= Tcl_WideAsDouble(LLONG_MAX)+0.5) {
+		    goto tooLarge;
+		}
+		PUSH_OBJECT(Tcl_NewWideIntObj(Tcl_DoubleAsWide(d + 0.5)));
+	    } else {
+		PUSH_OBJECT(Tcl_NewLongObj((long) (d + 0.5)));
 	    }
-	    temp = (long) (d + 0.5);
 	}
-	if (IS_NAN(temp) || IS_INF(temp)) {
-	    TclExprFloatError(interp, temp);
-	    return TCL_ERROR;
-	}
-	iResult = (long) temp;
     }
 
     /*
-     * Push a Tcl object with the result.
-     */
-    
-    PUSH_OBJECT(Tcl_NewLongObj(iResult));
-
-    /*
      * Reflect the change to stackTop back in eePtr.
      */
 
-    done:
     TclDecrRefCount(valuePtr);
     return TCL_OK;
 }
