Tcl Source Code

Check-in [0e9fcc9b56]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:
[kennykb-numerics-branch]
* generic/tclExecute.c: Bug fix. INST_RSHIFT: shift of negative values produced incorrect results.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | kennykb-numerics-branch
Files: files | file ages | folders
SHA1:0e9fcc9b560ec5b9ee2f0f121d0bec4fa507887e
User & Date: dgp 2005-08-25 21:21:33
Context
2005-08-29
17:11
[kennykb-numerics-branch]
* generic/tclBasic.c: Restored round(.) to the Tcl 8.4 ...
check-in: 2088e4d384 user: dgp tags: kennykb-numerics-branch
2005-08-25
21:21
[kennykb-numerics-branch]
* generic/tclExecute.c: Bug fix. INST_RSHIFT: shift of n...
check-in: 0e9fcc9b56 user: dgp tags: kennykb-numerics-branch
15:46
[kennykb-numerics-branch] Merge updates from HEAD
* generic/tclExecute.c: Bug fix. ...
check-in: 6d651867f9 user: dgp tags: kennykb-numerics-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

4
5
6
7
8
9
10



11
12
13
14
15
16
17
18
	duplicated object on the floor, which was a memory leak (and a wrong
	result too). Thanks to Andreas Kupries for reporting this.

2005-08-25  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch] Merge updates from HEAD




	* generic/tclExecute.c:	Bug fix.  INST_*SHIFT* opcodes stack
	management. [expr 0<<6] should be 0, not 6.

	* generic/tclBasic.c:	Extended the domain of round(.) to all
	non-Inf, non-NaN doubles, using bignums for the result as needed.

2005-08-24  Andreas Kupries <andreask@activestate.com>








>
>
>
|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	duplicated object on the floor, which was a memory leak (and a wrong
	result too). Thanks to Andreas Kupries for reporting this.

2005-08-25  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch] Merge updates from HEAD

	* generic/tclExecute.c: Bug fix.  INST_RSHIFT: shift of negative
	values produced incorrect results.

	* generic/tclExecute.c:	Bug fix.  INST_*SHIFT opcodes stack
	management. [expr 0<<6] should be 0, not 6.

	* generic/tclBasic.c:	Extended the domain of round(.) to all
	non-Inf, non-NaN doubles, using bignums for the result as needed.

2005-08-24  Andreas Kupries <andreask@activestate.com>

Changes to generic/tclExecute.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3850
3851
3852
3853
3854
3855
3856

3857
3858
3859
3860
3861
3862
3863
3864













3865
3866
3867
3868
3869
3870
3871
 * Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
 * Copyright (c) 2002-2005 by Miguel Sofer.
 * Copyright (c) 2005 by Donal K. Fellows.
 *
 * 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.37 2005/08/25 15:46:30 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include "tommath.h"

#include <math.h>
................................................................................
		    "integer value too large to represent", -1));
	    goto checkForCatch;
	}
	mp_init(&bigResult);
	if (*pc == INST_LSHIFT) {
	    mp_mul_2d(&big1, shift, &bigResult);
	} else {

	    mp_div_2d(&big1, shift, &bigResult, NULL);
	    if (mp_iszero(&bigResult) && big1.sign == MP_NEG) {
		/* When right shifting a negative value, keep the sign bit */
		/* TODO: consider direct SetLongObj to -1 */
		mp_int bigOne;
		Tcl_GetBignumFromObj(NULL, eePtr->constants[1], &bigOne);
		mp_sub(&bigResult, &bigOne, &bigResult);
	    }













	}
	mp_clear(&big1);
	TRACE(("%s %s => ", O2S(valuePtr), O2S(value2Ptr)));
	if (Tcl_IsShared(valuePtr)) {
	    objResultPtr = Tcl_NewBignumObj(&bigResult);
	    TRACE(("%s\n", O2S(objResultPtr)));
	    NEXT_INST_F(1, 2, 1);







|







 







>








>
>
>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
 * Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
 * Copyright (c) 2002-2005 by Miguel Sofer.
 * Copyright (c) 2005 by Donal K. Fellows.
 *
 * 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.38 2005/08/25 21:21:33 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include "tommath.h"

#include <math.h>
................................................................................
		    "integer value too large to represent", -1));
	    goto checkForCatch;
	}
	mp_init(&bigResult);
	if (*pc == INST_LSHIFT) {
	    mp_mul_2d(&big1, shift, &bigResult);
	} else {
#if 0
	    mp_div_2d(&big1, shift, &bigResult, NULL);
	    if (mp_iszero(&bigResult) && big1.sign == MP_NEG) {
		/* When right shifting a negative value, keep the sign bit */
		/* TODO: consider direct SetLongObj to -1 */
		mp_int bigOne;
		Tcl_GetBignumFromObj(NULL, eePtr->constants[1], &bigOne);
		mp_sub(&bigResult, &bigOne, &bigResult);
	    }
#else
	    mp_int bigRemainder;
	    mp_init(&bigRemainder);
	    mp_div_2d(&big1, shift, &bigResult, &bigRemainder);
	    if (!mp_iszero(&bigRemainder) && (bigRemainder.sign == MP_NEG)) {
		/* Convert to Tcl's integer division rules */
		mp_int bigOne;
		Tcl_GetBignumFromObj(NULL, eePtr->constants[1], &bigOne);
		mp_sub(&bigResult, &bigOne, &bigResult);
		mp_clear(&bigOne);
	    }
	    mp_clear(&bigRemainder);
#endif
	}
	mp_clear(&big1);
	TRACE(("%s %s => ", O2S(valuePtr), O2S(value2Ptr)));
	if (Tcl_IsShared(valuePtr)) {
	    objResultPtr = Tcl_NewBignumObj(&bigResult);
	    TRACE(("%s\n", O2S(objResultPtr)));
	    NEXT_INST_F(1, 2, 1);