Sponsored Content
Top Forums Shell Programming and Scripting TCL scripting: errorInfo=integer value too large to represent Post 302996138 by drl on Wednesday 19th of April 2017 04:28:49 PM
Old 04-19-2017
Hi.

Noting that:
Quote:
int arg
The argument may be any numeric value. The integer part of arg is determined, and then the low order bits of that integer value up to the machine word size are returned as an integer value. For reference, the number of bytes in the machine word are stored in the wordSize element of the tcl_platform array.
mathfunc manual page - Tcl Mathematical Functions

Stripping the statements down to this:
Code:
#!/usr/bin/env tclsh

# @(#) tcl1     Demonstrate tclsh feature.

puts stdout ""
set version [ info tclversion ]
set message " Hello, world from tclsh ($version)"
puts stdout $message

set first 123456789110000
set next  1234

set sum [expr {$first+$next}]
puts " Sum of $first plus $next is $sum"

produces:
Code:
./tcl1

 Hello, world from tclsh (8.6)
 Sum of 123456789110000 plus 1234 is 123456789111234

On a system like:
Code:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution        : Debian 8.7 (jessie) 
tclsh 8.6

Best wishes ... cheers, drl

Last edited by drl; 04-20-2017 at 02:30 PM.. Reason: Correct minor typo
This User Gave Thanks to drl For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is $PROD ? Does it represent some Unix directory?

Hi , Could u tell me What is $PROD ? Does it represent some Unix directory? Regards Ashish Malviya (2 Replies)
Discussion started by: Ashishm
2 Replies

2. Shell Programming and Scripting

How to represent euro sign in unix

how should represent euro sign "€" in Unix (1 Reply)
Discussion started by: akash
1 Replies

3. Solaris

Disk Representation - what is this c1t1d0s2 represent?

Hi All, Can you please advise what the 't' letters stands for? I understand the letter for the following "c1t1d0s2": c = disk Controller t = ? d = disk number ID. s = slice or partition of the disk Thanks (2 Replies)
Discussion started by: tlee
2 Replies

4. Shell Programming and Scripting

expr: Integer argument too large

Hi all, In KSH, I have got an error message like, "expr: Integer argument too large" I received this error message when I mutiply two large values and displaying the resultant output. Is there any other altenative way to go with too large values? Kindly let me know asap... Thanks in... (12 Replies)
Discussion started by: iamgeethuj
12 Replies

5. Shell Programming and Scripting

Scripting the process to edit a large file

Hi, I need to make a script to edit a file. File is a large file in below format Version: 2008120101 ;$INCLUDE ./abc/xyz/Delhi ;$INCLUDE ./abc/xyz/London $INCLUDE ./abc/xyz/New York First line in the file is version number which is in year,month,date and serial number format. Each... (5 Replies)
Discussion started by: makkar4u
5 Replies

6. Emergency UNIX and Linux Support

TCL scripting - searching for a IP address in a string

Hi All, Can anyone please help me with the regular expression/code snippet to search for an IP address in a string with Tcl scripting. Example string "OSPF_NBRUP OSPF neighbor 16.138.181.15 (realm ospf-v2 e1-0/0/0:37.0 area 0.0.0.0) state changed from Full to Down due to KillNbr" In the... (6 Replies)
Discussion started by: Mr. Zer0
6 Replies

7. UNIX for Dummies Questions & Answers

What does $ represent in command prompt?

What does $ represent in command prompt? (2 Replies)
Discussion started by: ashok.g
2 Replies

8. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

9. Shell Programming and Scripting

How to convert string into integer in shell scripting?

Hi All, sessionid_remote=$(echo "select odb_sessionid from sysopendb where odb_dbname='syscdr';" | sudo -u cucluster ssh ucbu-aricent-vm93 "source /opt/cisco/connection/lib/connection.profile; $INFORMIXDIR/bin/dbaccess sysmaster@ciscounity") for sid in $sessionid_remote;do if * ]];... (2 Replies)
Discussion started by: deeptis
2 Replies

10. Shell Programming and Scripting

TCL scripting: errorInfo=integer value too large to represent

The username is of the format : 123456789110000-1234@something.com With this below TCL procedure, I am trying add first and Sec Id and get third Id. I checked in online compiler and it seems to work and add. However, when I am running this in my lab, I get error as "integer value too large to... (1 Reply)
Discussion started by: Shaibal_bp
1 Replies
mathfunc(n)						    Tcl Mathematical Functions						       mathfunc(n)

__________________________________________________________________________________________________________________________________________________

NAME
mathfunc - Mathematical functions for Tcl expressions SYNOPSIS
package require Tcl 8.5 ::tcl::mathfunc::abs arg ::tcl::mathfunc::acos arg ::tcl::mathfunc::asin arg ::tcl::mathfunc::atan arg ::tcl::mathfunc::atan2 y x ::tcl::mathfunc::bool arg ::tcl::mathfunc::ceil arg ::tcl::mathfunc::cos arg ::tcl::mathfunc::cosh arg ::tcl::mathfunc::double arg ::tcl::mathfunc::entier arg | ::tcl::mathfunc::exp arg ::tcl::mathfunc::floor arg ::tcl::mathfunc::fmod x y ::tcl::mathfunc::hypot x y ::tcl::mathfunc::int arg ::tcl::mathfunc::isqrt arg ::tcl::mathfunc::log arg ::tcl::mathfunc::log10 arg ::tcl::mathfunc::max arg ?arg ...? ::tcl::mathfunc::min arg ?arg ...? ::tcl::mathfunc::pow x y ::tcl::mathfunc::rand ::tcl::mathfunc::round arg ::tcl::mathfunc::sin arg ::tcl::mathfunc::sinh arg ::tcl::mathfunc::sqrt arg ::tcl::mathfunc::srand arg ::tcl::mathfunc::tan arg ::tcl::mathfunc::tanh arg ::tcl::mathfunc::wide arg _________________________________________________________________ DESCRIPTION
The expr command handles mathematical functions of the form sin($x) or atan2($y,$x) by converting them to calls of the form [tcl::math- func::sin [expr {$x}]] or [tcl::mathfunc::atan2 [expr {$y}] [expr {$x}]]. A number of math functions are available by default within the namespace ::tcl::mathfunc; these functions are also available for code apart from expr, by invoking the given commands directly. Tcl supports the following mathematical functions in expressions, all of which work solely with floating-point numbers unless otherwise noted: abs acos asin atan atan2 bool ceil cos cosh double entier exp floor fmod hypot int isqrt log log10 max min pow rand round sin sinh sqrt srand tan tanh wide In addition to these predefined functions, applications may define additional functions by using proc (or any other method, such as interp alias or Tcl_CreateObjCommand) to define new commands in the tcl::mathfunc namespace. In addition, an obsolete interface named Tcl_Cre- ateMathFunc() is available to extensions that are written in C. The latter interface is not recommended for new implementations. DETAILED DEFINITIONS abs arg Returns the absolute value of arg. Arg may be either integer or floating-point, and the result is returned in the same form. acos arg Returns the arc cosine of arg, in the range [0,pi] radians. Arg should be in the range [-1,1]. asin arg Returns the arc sine of arg, in the range [-pi/2,pi/2] radians. Arg should be in the range [-1,1]. atan arg Returns the arc tangent of arg, in the range [-pi/2,pi/2] radians. atan2 y x Returns the arc tangent of y/x, in the range [-pi,pi] radians. x and y cannot both be 0. If x is greater than 0, this is equiva- lent to "atan [expr {y/x}]". bool arg Accepts any numeric value, or any string acceptable to string is boolean, and returns the corresponding boolean value 0 or 1. Non- zero numbers are true. Other numbers are false. Non-numeric strings produce boolean value in agreement with string is true and string is false. ceil arg Returns the smallest integral floating-point value (i.e. with a zero fractional part) not less than arg. The argument may be any numeric value. cos arg Returns the cosine of arg, measured in radians. cosh arg Returns the hyperbolic cosine of arg. If the result would cause an overflow, an error is returned. double arg The argument may be any numeric value, If arg is a floating-point value, returns arg, otherwise converts arg to floating-point and returns the converted value. May return Inf or -Inf when the argument is a numeric value that exceeds the floating-point range. entier arg The argument may be any numeric value. The integer part of arg is determined and returned. The integer range returned by this | function is unlimited, unlike int and wide which truncate their range to fit in particular storage widths. exp arg Returns the exponential of arg, defined as e**arg. If the result would cause an overflow, an error is returned. floor arg Returns the largest integral floating-point value (i.e. with a zero fractional part) not greater than arg. The argument may be any numeric value. fmod x y Returns the floating-point remainder of the division of x by y. If y is 0, an error is returned. hypot x y Computes the length of the hypotenuse of a right-angled triangle "sqrt [expr {x*x+y*y}]". int arg The argument may be any numeric value. The integer part of arg is determined, and then the low order bits of that integer value up to the machine word size are returned as an integer value. For reference, the number of bytes in the machine word are stored in tcl_platform(wordSize). isqrt arg Computes the integer part of the square root of arg. Arg must be a positive value, either an integer or a floating point number. Unlike sqrt, which is limited to the precision of a floating point number, isqrt will return a result of arbitrary precision. log arg Returns the natural logarithm of arg. Arg must be a positive value. log10 arg Returns the base 10 logarithm of arg. Arg must be a positive value. max arg ... Accepts one or more numeric arguments. Returns the one argument with the greatest value. min arg ... Accepts one or more numeric arguments. Returns the one argument with the least value. pow x y Computes the value of x raised to the power y. If x is negative, y must be an integer value. rand Returns a pseudo-random floating-point value in the range (0,1). The generator algorithm is a simple linear congruential generator that is not cryptographically secure. Each result from rand completely determines all future results from subsequent calls to rand, so rand should not be used to generate a sequence of secrets, such as one-time passwords. The seed of the generator is initialized from the internal clock of the machine or may be set with the srand function. round arg If arg is an integer value, returns arg, otherwise converts arg to integer by rounding and returns the converted value. sin arg Returns the sine of arg, measured in radians. sinh arg Returns the hyperbolic sine of arg. If the result would cause an overflow, an error is returned. sqrt arg The argument may be any non-negative numeric value. Returns a floating-point value that is the square root of arg. May return Inf when the argument is a numeric value that exceeds the square of the maximum value of the floating-point range. srand arg The arg, which must be an integer, is used to reset the seed for the random number generator of rand. Returns the first random num- ber (see rand) from that seed. Each interpreter has its own seed. tan arg Returns the tangent of arg, measured in radians. tanh arg Returns the hyperbolic tangent of arg. wide arg The argument may be any numeric value. The integer part of arg is determined, and then the low order 64 bits of that integer value are returned as an integer value. SEE ALSO
expr(n), mathop(n), namespace(n) COPYRIGHT
Copyright (c) 1993 The Regents of the University of California. Copyright (c) 1994-2000 Sun Microsystems Incorporated. Copyright (c) 2005, 2006 by Kevin B. Kenny <kennykb@acm.org>. Tcl 8.5 mathfunc(n)
All times are GMT -4. The time now is 04:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy