Tcl Script Learning five: basic operations

Source: Internet
Author: User

Lesson 5: Basic Mathematical calculations

1. Set X 100;
Set Y 256;
Set Z [expr "$Y + $X"]
Can also be written as set Z [expr {$Y + $X}]


2. Set Z_label "$Y plus $X is"
Puts "$Z _label $Z"
Puts "The square root of $Y is [expr sqrt ($Y)]\n"
The formula for finding the root of expr is usually taken [] as the return value

3.puts "Because of the precedence rules \" 5 +-3 * 4\ "is: [expr-3 * 4 + 5]"
Puts "Because of the Parentheses \" (5 +-3) * 4\ "is: [Expr (5 +-3) * 4]"
Basic rules of operation
Puts "\ n ... more examples of differences between \" and \{"..... more
puts {$Z _label [expr $Y + $X]}
Puts "$Z _label {[expr $Y + $X]}"
Puts "the command to add both numbers is: \[expr \ $a + \ $b]"
Examples of parentheses

Tcl Script Learning five: basic operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.