*** generic/tclExecute.c	2 Nov 2004 15:32:06 -0000	1.166
--- generic/tclExecute.c	6 Nov 2004 00:28:39 -0000
***************
*** 146,151 ****
--- 146,167 ----
  #define IS_INF(v) (((v) > DBL_MAX) || ((v) < -DBL_MAX))
  
  /*
+  *  Windows hacks.
+  */
+ #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MSVCRT__))
+ #   define MASK87_DECLARE \
+ 	int mask
+ 
+ #   define MASK87_SAVE \
+ 	mask = _controlfp(0, 0); \
+ 	_controlfp(_CW_DEFAULT, _MCW_EM)
+ 
+ #   define MASK87_RESTORE \
+ 	_clear87(); \
+ 	_controlfp(mask, _MCW_EM)
+ #endif
+ 
+ /*
   * The new macro for ending an instruction; note that a
   * reasonable C-optimiser will resolve all branches
   * at compile time. (result) is always a constant; the macro 
***************
*** 5563,5569 ****
  {
      register Tcl_Obj *valuePtr;
      double d, dResult;
!     
      double (*func) _ANSI_ARGS_((double)) =
  	(double (*)_ANSI_ARGS_((double))) clientData;
  
--- 5579,5586 ----
  {
      register Tcl_Obj *valuePtr;
      double d, dResult;
!     MASK87_DECLARE;
! 
      double (*func) _ANSI_ARGS_((double)) =
  	(double (*)_ANSI_ARGS_((double))) clientData;
  
***************
*** 5581,5587 ****
--- 5598,5606 ----
      GET_DOUBLE_VALUE(d, valuePtr, valuePtr->typePtr);
  
      errno = 0;
+     MASK87_SAVE;
      dResult = (*func)(d);
+     MASK87_RESTORE;
      if ((errno != 0) || IS_NAN(dResult) || IS_INF(dResult)) {
  	TclExprFloatError(interp, dResult);
  	return TCL_ERROR;
***************
*** 5607,5613 ****
  {
      register Tcl_Obj *valuePtr, *value2Ptr;
      double d1, d2, dResult;
!     
      double (*func) _ANSI_ARGS_((double, double))
  	= (double (*)_ANSI_ARGS_((double, double))) clientData;
  
--- 5626,5633 ----
  {
      register Tcl_Obj *valuePtr, *value2Ptr;
      double d1, d2, dResult;
!     MASK87_DECLARE;
! 
      double (*func) _ANSI_ARGS_((double, double))
  	= (double (*)_ANSI_ARGS_((double, double))) clientData;
  
***************
*** 5628,5634 ****
--- 5648,5656 ----
      GET_DOUBLE_VALUE(d2, value2Ptr, value2Ptr->typePtr);
  
      errno = 0;
+     MASK87_SAVE;
      dResult = (*func)(d1, d2);
+     MASK87_RESTORE;
      if ((errno != 0) || IS_NAN(dResult) || IS_INF(dResult)) {
  	TclExprFloatError(interp, dResult);
  	return TCL_ERROR;

