In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use bc commands in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use bc commands in Linux" this article.
Bc command is a calculator language that supports interactive execution of arbitrary precision. Bash has built-in support for four operations of integers, but does not support floating-point operations, and the bc command can easily perform floating-point operations, and of course integer operations are no longer needed.
Bc arithmetic operation precision operation tool
Syntax bc (option) (parameter) option-I: force to enter interactive mode;-l: define the standard math library to be used;-w: give a warning message to the extension of POSIX bc;-Q: do not print normal GNU bc environment information;-v: display instruction version information;-h: display instruction help information. Parameter file: specifies the file that contains the calculation task.
Example arithmetic operation advanced operation bc command it can perform floating-point operations and some advanced functions:
Echo "1.212: 3" | bc 3.636 sets the decimal precision (value range)
Echo "scale=2;3/8" | bc 0.37Parameter scale=2 sets the decimal place of the bc output to 2 places.
Binary conversion
#! / bin/bash abc=192 echo "obase=2;$abc" | the result of bc execution is 11000000, which converts decimal to binary with bc.
#! / bin/bash abc=11000000 echo "obase=10;ibase=2;$abc" | the result of bc execution is 192, which converts binary to decimal with bc.
Calculate the sum of square roots:
Echo "10 ^ 10" | bc echo "sqrt (100)" | the above bc is all the contents of the article "how to use bc commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.