Tcl Source Code

Check-in [2435e3e70d]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:
* generic/tclBasic.c: Re-implemented ExprRoundFunc and ExprEntierFunc to use TclGetNumberFromObj.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | kennykb-numerics-branch
Files: files | file ages | folders
SHA1: 2435e3e70dfea542acf4cb05bec16000f083f10c
User & Date: dgp 2005-10-03 19:32:41
Context
2005-10-04
13:49
[kennykb-numerics-branch]
* generic/tclBasic.c: Updated more callers to make use ...
check-in: 215aa64c5c user: dgp tags: kennykb-numerics-branch
2005-10-03
19:32
* generic/tclBasic.c: Re-implemented ExprRoundFunc and ExprEntierFunc to use TclGe...
check-in: 2435e3e70d user: dgp tags: kennykb-numerics-branch
18:25
Be more choosy about what doubles get converted to longs. check-in: 9fd8db27ff user: dgp tags: kennykb-numerics-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1
2
3
4
5
6
7
8
9
10
11
12
13
2005-10-03  Don Porter  <[email protected]>

	[kennykb-numerics-branch]

	* generic/tclBasic.c:	Re-implemented ExprRoundFunc to use
	TclGetNumberFromObj.

	* generic/tclInt.h:	Added new routine TclGetNumberFromObj to
	* generic/tclObj.c:	provide efficient access to the actual
	internal rep of a numeric Tcl_Obj without conversions.

2005-09-30  Don Porter  <[email protected]>




|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
2005-10-03  Don Porter  <[email protected]users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclBasic.c:	Re-implemented ExprRoundFunc and ExprEntierFunc
	to use TclGetNumberFromObj.

	* generic/tclInt.h:	Added new routine TclGetNumberFromObj to
	* generic/tclObj.c:	provide efficient access to the actual
	internal rep of a numeric Tcl_Obj without conversions.

2005-09-30  Don Porter  <[email protected]>

Changes to generic/tclBasic.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
5325
5326
5327
5328
5329
5330
5331
5332


5333
5334
5335
5336
5337
5338
5339
5340
5341


5342
5343

5344
5345
5346

5347
5348


5349
5350




5351
5352
5353
5354
5355
5356
5357
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 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: tclBasic.c,v 1.136.2.37 2005/10/03 18:25:19 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include <float.h>
#include <math.h>
#include "tommath.h"
................................................................................
    ClientData clientData;	/* Ignored. */
    Tcl_Interp *interp;		/* The interpreter in which to execute the
				 * function. */
    int objc;			/* Actual parameter count */
    Tcl_Obj *CONST *objv;	/* Actual parameter vector */
{
    double d;
    mp_int big;


    if (objc != 2) {
	MathFuncWrongNumArgs(interp, 2, objc, objv);
	return TCL_ERROR;
    }
    if (Tcl_GetBignumFromObj(NULL, objv[1], &big) == TCL_OK) {
	mp_clear(&big);
	Tcl_SetObjResult(interp, objv[1]);
	return TCL_OK;
    }


    if (Tcl_GetDoubleFromObj(interp, objv[1], &d) != TCL_OK) {
	/* Non-numeric argument */

	return TCL_ERROR;
    }
    if (TclInitBignumFromDouble(interp, d, &big) != TCL_OK) {

	return TCL_ERROR;
    }


    Tcl_SetObjResult(interp, Tcl_NewBignumObj(&big));
    return TCL_OK;




}

static int
ExprIntFunc(clientData, interp, objc, objv)
    ClientData clientData;	/* Ignored. */
    Tcl_Interp *interp;		/* The interpreter in which to execute the
				 * function. */






|







 







|
>
>




|
<
<
|

>
>
|
|
>
|
|
<
>
|

>
>
|
|
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339


5340
5341
5342
5343
5344
5345
5346
5347
5348

5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-1999 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 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: tclBasic.c,v 1.136.2.38 2005/10/03 19:32:42 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"
#include <float.h>
#include <math.h>
#include "tommath.h"
................................................................................
    ClientData clientData;	/* Ignored. */
    Tcl_Interp *interp;		/* The interpreter in which to execute the
				 * function. */
    int objc;			/* Actual parameter count */
    Tcl_Obj *CONST *objv;	/* Actual parameter vector */
{
    double d;
    int type;
    ClientData ptr;

    if (objc != 2) {
	MathFuncWrongNumArgs(interp, 2, objc, objv);
	return TCL_ERROR;
    }
    if (TclGetNumberFromObj(interp, objv[1], &ptr, &type) != TCL_OK) {


	return TCL_ERROR;
    }
    if (type == TCL_NUMBER_DOUBLE) {
	mp_int big;
	if (TclInitBignumFromDouble(interp, *((CONST double *)ptr), &big)
		!= TCL_OK) {
	    /* Infinity */
	    return TCL_ERROR;
	}

	Tcl_SetObjResult(interp, Tcl_NewBignumObj(&big));
	return TCL_OK;
    }
    if (type != TCL_NUMBER_NAN) {
	/* All integers are already of integer type */
	Tcl_SetObjResult(interp, objv[1]);
	return TCL_OK;
    }
    /* Get the error message for NaN */
    Tcl_GetDoubleFromObj(interp, objv[1], &d);
    return TCL_ERROR;
}

static int
ExprIntFunc(clientData, interp, objc, objv)
    ClientData clientData;	/* Ignored. */
    Tcl_Interp *interp;		/* The interpreter in which to execute the
				 * function. */