Magic Calculator for DC and BC

Source: Internet
Author: User
Tags ibase

Magic Calculator for DC and BC

Linux is the P244.
Http://baike.baidu.com/link?url= Ylttivbfc1tfzreeuqoe8d0c6yqwbzgqnmlobq1hjvadxxlatniwkkhli9u-4txwd4cuxos6oqnwiesmyoxulue_zhko3fevdzbnxhi4xpg

DC old, is the abbreviation of desk caclulator, use inverse Polish style to express the formula
BC to appear later, 1975 BC is the basic Calculator basic calculator abbreviation, BC program does not support interaction, GNU BC can be used with the read command to interact
Both BC and DC are compiled into bytecode like Java, and then interpreted by the virtual machine for execution.

We generally use algebraic notation 1+1=2 3*6 =18,BC can handle
But DC can only use inverse Polish style 11 +, 3 6 *

Most Linux distributions now use the GNU version of the BC, which has a high-level language feature
variables, arrays, sub-processes, select branches, loops

BC also has an exit status
0 indicates success
1 indicates a syntax error
Other values are not strictly defined


The use of Linux commands provides an interpreter for any precision arithmetic language. The meaning of BC is: Binary Calculator, which is used to achieve arbitrary precision calculations (often high-precision computations). Syntax BC [-c] [-l] [File ...]
Specify the-C (compile-only) flag
Functions in the-I math library
Description The BC command is an interactive process that provides arbitrary precision arithmetic. The BC command first reads any input file specified by the file parameter and then reads the standard input. The input file must be a text file containing the command sequence, statement, or function definition that the BC command can read and execute. The BC command is a preprocessor for the DC command. It automatically calls the DC command unless you specify the-C (compile-only) flag. If the-c flag is specified, the output from the BC command goes to standard output. The BC command allows you to specify input and output binaries for decimal, octal, or hexadecimal operations. The default value is decimal. This command also provides a scaling rule for decimal point symbols. The BC command always uses the. (dot number) to represent the cardinality point, regardless of any decimal point character specified as part of the current locale. The syntax of the BC command is similar to the syntax of the C language. You can use the BC command to convert between the binaries by assigning the IBase keyword to the input and the Obase keyword to the output binary. A range of 2 to 16 is valid for the IBase keyword. The Obase keyword ranges from 2 until the limit of the Bc_base_max value that is defined in the/usr/include/sys/limits.h file is set. Regardless of the settings of IBase and Obase, the BC Command recognizes the letters A through F as their hexadecimal values 10 through 15. The output of the BC command is controlled by the read. The output consists of one or more rows of values that contain all executed unassigned expressions. The cardinality and precision of the output is controlled by the value of the obase and scale keywords. Further information about how the BC command handles information from source files is described in the following sections: * syntax * Lexical conventions * identifiers and operators * expressions * statements * Function calls *-I math library function syntax The following syntax describes the syntax of the BC program, where program represents any valid programs :

Magic Calculator for DC and BC

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.