Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Dc (computer program)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Input/output== To read a line from [[stdin]], use the <code>?</code> command. This evaluates the line as if it were a dc command, and so it is necessary that it be syntactically correct and presents a potential security problem because the <code>!</code> dc command enables arbitrary command execution. As mentioned above, <code>p</code> prints the top of the stack with a newline after it. <code>n</code> pops the top of the stack and prints it without a trailing newline. <code>f</code> prints the entire stack with one entry per line. dc also supports arbitrary input and output [[radix|radices]]. The <code>i</code> command pops the top of the stack and uses it for the input base. Hex digits must be in upper case to avoid collisions with dc commands and are limited to A-F. The <code>o</code> command does the same for the output base, but keep in mind that the input base affects the parsing of every numeric value afterwards so it is usually advisable to set the output base first. Therefore <code>10o</code> sets the output radix to the current input radix, but generally not to 10 (ten). Nevertheless <code>Ao</code> resets the output base to 10 (ten), regardless of the input base. To read the values, the <code>K</code>, <code>I</code> and <code>O</code> commands push the current precision, input radix and output radix on to the top of the stack. As an example, to convert from hex to binary: <syntaxhighlight lang="console"> $ echo 16i2o DEADBEEFp | dc 11011110101011011011111011101111 </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)