From 5d14e46cbcfe16a1f15d35132879b45a6fe5477c Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Wed, 24 Aug 2005 18:56:32 +0000 Subject: corrected TRACE bugs, overflowed negative #s, and bad test constraints --- ChangeLog | 55 ++++++++++++++++++++++++++++++++-------------------- generic/tclExecute.c | 7 ++++--- generic/tclStrToD.c | 51 ++++++++++++++++++++++-------------------------- tests/binary.test | 22 ++++++++++----------- tests/expr.test | 6 +++--- 5 files changed, 75 insertions(+), 66 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f6fba6..fcc7931 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,19 @@ +2005-08-24 Kevin Kenny + + [kennykb-numerics-branch] + + * generic/tclExecute.c: Corrected some TRACE bugs that prevented + compilation with --enable-symbols=all. + * generic/tclStrToD.c: Revised commentary to prepare for a + renaming of the file, removed some dead code, and fixed a bug + where TclBignumToDouble failed on huge negative numbers. + * tests/binary.test (binary-65.*): Added missing 'ieeeFloatingPoint' to + large/small significand tests. + * tests/expr.test (expr-45.*) Added missing braces around expressions. + 2005-08-24 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: Bug fix: TclBignumToDouble return -Inf when appropriate. Removed declarations of removed routines. @@ -11,7 +24,7 @@ 2005-08-23 Kevin Kenny - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclCmdMZ.c (Tcl_StringObjCmd): * generic/tclInt.h: @@ -37,7 +50,7 @@ 2005-08-23 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclStrToD.c: Bug fix: set shift magnitude properly whether we're expanding to mp_int type or not. @@ -70,7 +83,7 @@ 2005-08-22 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclInt.h: New ACCEPT_NAN macro to mark code that supports * generic/tclCmdAH.c: or disables accepting of the NaN value at @@ -102,7 +115,7 @@ 2005-08-21 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclInt.h: Moved TclParseInteger to tclUtil.c * generic/tclParseExpr.c: and made it static. @@ -128,7 +141,7 @@ 2005-08-19 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclBasic.c: Updated OldMathFuncProc and ExprAbsFunc to do less invasion into numeric Tcl_Obj internals. Made ExprDoubleFunc, @@ -153,7 +166,7 @@ 2005-08-18 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: Fixed string rep invalidation bug in * tests/dict.test (dict-11.17): INST_DICT_INCR_IMM rewrite. @@ -165,7 +178,7 @@ 2005-08-17 Kevin Kenny - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclBasic.c (Tcl_Expr{Long,Double}{,Obj}): Updated to * generic/tclTest.c: deal with @@ -182,7 +195,7 @@ 2005-08-17 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: New routine TclIncrObj to centralize the increment operation needed in many places. Updated @@ -190,7 +203,7 @@ 2005-08-16 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: Made bit shifting opcodes and INST_MOD bignum-aware. @@ -210,7 +223,7 @@ 2005-08-15 Don Porter - [kennykb_numerics_branch] Updates from HEAD. + [kennykb-numerics-branch] Updates from HEAD. * generic/tclExecute.c: More revisions to IllegalExprOperandType. Merged INST_BITNOT with INST_UMINUS and make it bignum-aware according to the rule: ~a = -a - 1. Disabled unused code and @@ -230,7 +243,7 @@ 2005-08-14 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: Updated execution of arithmetic bytecodes to be bignum-aware, and to allow calculations on NaN to produce @@ -243,7 +256,7 @@ 2005-08-13 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclObj.c: Extended Bignum auto-narrowing to auto-narrow to tclWideIntType when appropriate; this helps keep things working as @@ -257,7 +270,7 @@ 2005-08-12 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: Simplify doCondJump. Use eePtr->constants as result of INST_DICT_NEXT, INST_LAND, and INST_LOR. Separate @@ -276,7 +289,7 @@ 2005-08-11 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclExecute.c: Rewrite of INST_LAND/INST_LOR to take advantage of loss of "pure double" issues. Merged INST_UPLUS @@ -309,7 +322,7 @@ 2005-08-10 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclTomMath.h: Added mp_shrink, mp_to_unsigned_bin, * unix/Makefile.in: mp_to_unsigned_bin_n, and mp_unsigned_bin_size @@ -345,7 +358,7 @@ 2005-08-08 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclObj.c: Replaced some goto's with loops and started use of BIGNUM_AUTO_NARROW and NO_WIDE_TYPE. @@ -358,7 +371,7 @@ 2005-08-05 Don Porter - [kennykb_numerics_branch] + [kennykb-numerics-branch] * generic/tclObj.c: Rewrote Tcl_GetDoubleFromObj(). 2005-08-05 Donal K. Fellows @@ -389,7 +402,7 @@ 2005-08-04 Don Porter - [kennykb_numerics_branch] Updated from HEAD + [kennykb-numerics-branch] Updated from HEAD * generic/tclObj.c: Rewrote Tcl_GetBooleanFromObj() and supporting routines to make use of TclParseNumber. This reduces the potential @@ -407,7 +420,7 @@ 2005-08-02 Don Porter - [kennykb_numerics_branch] Updated from HEAD + [kennykb-numerics-branch] Updated from HEAD 2005-07-30 Daniel Steffen @@ -584,7 +597,7 @@ 2005-07-12 Kevin Kenny - [kennykb_numerics_branch] Updated from HEAD + [kennykb-numerics-branch] Updated from HEAD * generic/tclCmdMZ.c (Tcl_StringObjCmd): * generic/tclInt.h: diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 199c046..c69b2f4 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclExecute.c,v 1.167.2.35 2005/08/24 18:03:11 dgp Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.167.2.36 2005/08/24 18:56:32 kennykb Exp $ */ #include "tclInt.h" @@ -2673,7 +2673,7 @@ TclExecuteByteCode(interp, codePtr) result = Tcl_GetBooleanFromObj(NULL, value2Ptr, &i2); if (result != TCL_OK) { TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(value2Ptr), - (value2Ptr->typePtr? valuewPtr->typePtr->name : "null"))); + (value2Ptr->typePtr? value2Ptr->typePtr->name : "null"))); IllegalExprOperandType(interp, pc, value2Ptr); goto checkForCatch; } @@ -5137,6 +5137,7 @@ TclExecuteByteCode(interp, codePtr) goto error; } /* -NaN => NaN */ + result = TCL_OK; NEXT_INST_F(1, 0, 0); } #endif @@ -5403,7 +5404,7 @@ TclExecuteByteCode(interp, codePtr) /* Non-numeric argument... */ if (*pc == INST_UPLUS) { /* ... +$NonNumeric => raise an error */ - TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", s, + TRACE(("\"%.20s\" => ILLEGAL TYPE %s \n", O2S(valuePtr), (valuePtr->typePtr? valuePtr->typePtr->name : "null"))); IllegalExprOperandType(interp, pc, valuePtr); goto checkForCatch; diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 5c932f6..89e97f3 100755 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -1,21 +1,20 @@ /* *---------------------------------------------------------------------- * - * tclStrToD.c -- + * tclDouble.c -- * - * This file contains a TclStrToD procedure that handles conversion of - * string to double, with correct rounding even where extended precision - * is needed to achieve that. It also contains a TclDoubleDigits - * procedure that handles conversion of double to string (at least the - * significand), and several utility functions for interconverting - * 'double' and the integer types. + * This file contains a collection of procedures for managing + * conversions to/from floating-point in Tcl. They include + * TclParseNumber, which parses numbers from strings; TclDoubleDigits, + * which formats numbers into strings of digits, and procedures for + * interconversion among 'double' and 'mp_int' types. * * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStrToD.c,v 1.1.2.32 2005/08/24 18:51:36 dgp Exp $ + * RCS: @(#) $Id: tclStrToD.c,v 1.1.2.33 2005/08/24 18:56:32 kennykb Exp $ * *---------------------------------------------------------------------- */ @@ -29,37 +28,33 @@ #include #include +/* + * Define TIP_114_FORMATS to accept 0b and 0o for binary and octal strings. + * Define KILL_OCTAL as well as TIP_114_FORMATS to suppress interpretation + * of numbers with leading zero as octal. (Ceterum censeo: numeros octonarios + * delendos esse.) + */ + #define TIP_114_FORMATS #undef KILL_OCTAL -#if 0 -/* Hack is out of date. tclInt.h unconditionally #include's errno.h - * (via tclPort.h). - */ /* - * The stuff below is a bit of a hack so that this file can be used in - * environments that include no UNIX, i.e. no errno: just arrange to use the - * errno from tclExecute.c here. + * This code supports (at least hypothetically), IBM, Cray, VAX and + * IEEE-754 floating point; of these, only IEEE-754 can represent NaN. + * IEEE-754 can be uniquely determined by radix and by the widths of + * significand and exponent. */ -#ifdef TCL_GENERIC_ONLY -# define NO_ERRNO_H -#endif - -#ifdef NO_ERRNO_H -extern int errno; /* Use errno from tclExecute.c. */ -# define ERANGE 34 -#endif -#endif - #if (FLT_RADIX == 2) && (DBL_MANT_DIG == 53) && (DBL_MAX_EXP == 1024) # define IEEE_FLOATING_POINT #endif /* - * gcc on x86 needs access to rounding controls. It is tempting to include - * fpu_control.h, but that file exists only on Linux; it is missing on Cygwin - * and MinGW. Most gcc-isms and ix86-isms are factored out here. + * gcc on x86 needs access to rounding controls, because of a questionable + * feature where it retains intermediate results as IEEE 'long double' values + * somewhat unpredictably. It is tempting to include fpu_control.h, but + * that file exists only on Linux; it is missing on Cygwin and MinGW. Most + * gcc-isms and ix86-isms are factored out here. */ #if defined(__GNUC__) && defined(__i386) diff --git a/tests/binary.test b/tests/binary.test index 5c35287..7d39291 100644 --- a/tests/binary.test +++ b/tests/binary.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: binary.test,v 1.18.2.7 2005/08/23 18:28:51 kennykb Exp $ +# RCS: @(#) $Id: binary.test,v 1.18.2.8 2005/08/24 18:56:32 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -2139,7 +2139,7 @@ testConstraint ieeeFloatingPoint [testIEEE] # scan/format infinities -test binary-62,1 {infinity} ieeeFloatingPoint { +test binary-62.1 {infinity} ieeeFloatingPoint { binary scan [binary format q Infinity] w w format 0x%016lx $w } 0x7ff0000000000000 @@ -2197,39 +2197,39 @@ test binary-64.2 {NaN} \ } \ -match glob -result NaN(*123456789abc) -test binary-65.1 {largest significand} { +test binary-65.1 {largest significand} ieeeFloatingPoint { binary scan [binary format w 0x3fcfffffffffffff] q d set d } 0.24999999999999997 -test binary-65.2 {smallest significand} { +test binary-65.2 {smallest significand} ieeeFloatingPoint { binary scan [binary format w 0x3fd0000000000000] q d set d } 0.25 -test binary-65.3 {largest significand} { +test binary-65.3 {largest significand} ieeeFloatingPoint { binary scan [binary format w 0x3fdfffffffffffff] q d set d } 0.49999999999999994 -test binary-65.4 {smallest significand} { +test binary-65.4 {smallest significand} ieeeFloatingPoint { binary scan [binary format w 0x3fe0000000000000] q d set d } 0.5 -test binary-65.5 {largest significand} { +test binary-65.5 {largest significand} ieeeFloatingPoint { binary scan [binary format w 0x3fffffffffffffff] q d set d } 1.9999999999999998 -test binary-65.6 {smallest significand} { +test binary-65.6 {smallest significand} ieeeFloatingPoint { binary scan [binary format w 0x4000000000000000] q d set d } 2.0 -test binary-65.7 {smallest significand} { +test binary-65.7 {smallest significand} ieeeFloatingPoint { binary scan [binary format w 0x434fffffffffffff] q d set d } 18014398509481982.0 -test binary-65.8 {largest significand} { +test binary-65.8 {largest significand} ieeeFloatingPoint { binary scan [binary format w 0x4350000000000000] q d set d } 18014398509481984.0 -test binary-65.8 {largest significand} { +test binary-65.8 {largest significand} ieeeFloatingPoint { binary scan [binary format w 0x4350000000000001] q d set d } 18014398509481988.0 diff --git a/tests/expr.test b/tests/expr.test index 03d14a3..2d4f15d 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: expr.test,v 1.30.2.21 2005/08/23 19:51:24 kennykb Exp $ +# RCS: @(#) $Id: expr.test,v 1.30.2.22 2005/08/24 18:56:32 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.1 @@ -6696,10 +6696,10 @@ test expr-45.7 {entier} { list [catch {expr entier(Inf)} result] $result } {1 {integer value too large to represent}} test expr-45.8 {entier} ieeeFloatingPoint { - list [catch {expr entier($ieeeValues(NaN))} result] $result + list [catch {expr {entier($ieeeValues(NaN))}} result] $result } {1 {floating point value is Not a Number}} test expr-45.9 {entier} ieeeFloatingPoint { - list [catch {expr entier($ieeeValues(-NaN))} result] $result + list [catch {expr {entier($ieeeValues(-NaN))}} result] $result } {1 {floating point value is Not a Number}} # cleanup -- cgit v0.12