Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Tcl/Tk 8.5 Programming Cookbook

You're reading from   Tcl/Tk 8.5 Programming Cookbook With over 100 recipes, this Cookbook is ideal for both beginners and advanced Tcl/Tk programmers. From the basics to creating applications, it‚Äôs full of indispensable tips and tricks to make the most of the language.

Arrow left icon
Product type Paperback
Published in Feb 2011
Publisher Packt
ISBN-13 9781849512985
Length 236 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (20) Chapters Close

Tcl/Tk 8.5 Programming Cookbook
Credits
About the Author
1. Acknowledgment
About the Reviewers
2. www.PacktPub.com
3. Preface
1. The Tcl Shell FREE CHAPTER 2. Using the Building Blocks Control Constructs 3. Error Handling 4. Handling String Expressions 5. Expanding String Functionality Using Lists 6. The Tcl Dictionary 7. File Operations 8. Tk GUI Programming with Tcl/Tk 9. Configuring and Controlling Tk Widgets 10. Geometry Management 11. Using Tcl Built-in Dialog Windows 12. Creating and Managing Menus 13. Creating the Address Book Application

Mathematical functions


Mathematical functions (such as sine and cosine) are replaced with a call to the Tcl mathfunc namespace. This does not require any additional syntax to access the namespace as it is called automatically. These are invoked by passing the Function followed by the value or values to evaluate to the expr command. Those functions that accept multiple arguments require that the arguments be comma delimited. The default Mathematical functions are listed below in alphabetical order. These functions require a specific syntax (for example expr {function(value,value)}) to be accessed, as described in the Computing mathematical expressions section that follows:

Function

Result

abs arg

Returns the absolute value of arg.

Numeric operators may be integer or floating-point. Value is returned in the same format.

acos arg

Returns the arc cosine of arg.

asin arg

Returns the arc sine of arg.

atan arg

Returns the Arc Tangent of x/y.

bool arg

Returns the Boolean value of arg where non-numeric values are true, otherwise the value is false.

ceil arg

Returns the smallest floating-point integer value not less than arg.

Any numeric value is acceptable.

cos arg

Returns the cosine of arg, measured in radians.

If the result produces an over-flow, an error is returned.

double arg

Converts arg to its floating-point value.

May return INF or INF when the numeric value is such that it exceeds the floating-point value.

entier arg

Converts arg to its integer value.

exp arg

Returns the exponential of arg.

If the result produces an over-flow, an error is returned.

floor arg

Returns the largest floating-point integer not greater than arg.

The argument may be any numeric value.

fmod x y

Returns the remainder of x/y as a floating-point integer.

If y is a zero (0), then an error is returned.

hypot x y

Returns the length of the hypotenuse of a right angled triangle.

int arg

Returns the low order bits of arg up to the machine word size.

isqrt arg

Returns the integer portion of the square root of arg.

Arg must be a positive value (integer or floating-point).

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

This function accepts one or more numeric values and returns the greatest.

min arg

This function accepts one or more numeric and returns the least one.

pow x y

Returns the value of x raised to the power y.

If x is zero (0), y must be an integer value.

rand

Returns a pseudo-random floating-point integer in the range of 0, 1.

round arg

Returns the rounded value of arg if arg is an integer value.

If arg is not an integer, it is converted to an integer by rounding and the converted value is returned.

sin arg

Returns the sine of arg as radians.

sinh arg

Returns the hyperbolic sin of arg.

If the result produces an over-flow, an error is returned.

sqrt arg

Returns the square root of arg.

Accepts any non-negative numeric value.

May return INF when the value is a numeric value that exceeds the square of the maximum value for the floating-point range.

srand arg

Resets the seed for the random number generator and returns a random number as described in rand.

tan arg

Returns the tangent of arg as radians.

tanh arg

Returns the hyperbolic tangent of arg.

wide arg

Returns the low order 64 bits of arg.

Accepts any numeric value.

You have been reading a chapter from
Tcl/Tk 8.5 Programming Cookbook
Published in: Feb 2011
Publisher: Packt
ISBN-13: 9781849512985
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image