Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the bc command of Linux system

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article analyzes "how to understand the bc command of Linux system". The content is detailed and easy to understand. Friends who are interested in "how to understand the bc commands of the Linux system" can follow the editor's train of thought to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "how to understand bc commands in Linux system".

Bash Shell has built-in support for integer operations, but does not support floating-point operations, and the Linux bc command can easily perform floating-point operations, and of course integer operations are no longer needed.

Syntax bc (option) (parameter) option value-I: force into interactive mode

-l: defines the standard math library used

;-w: give a warning about the extension of POSIX bc

-Q: do not print normal GNU bc environment information

-v: displays instruction version information

-h: displays the help information for the instruction.

Parameter file: specifies the file that contains the calculation task.

Case presentation $bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 2'3 5 5-2 3 2 3 3 1 5 enter quit to exit.

Through the pipe symbol

$echo "15 places 5" | set bc 20scale=2 to decimal places, and 2 means to retain two places:

$echo 'scale=2; (2.777-1.4744) / 1' | bc 1.30bc not only sets decimal places by scale, but also uses ibase and obase for other base operations:

$echo "ibase=2;111" | bc 7-ary 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 10000000000$ echo "sqrt (100)" | bc 10 is here to share how to understand the bc command of the Linux system. I hope the above content can improve everyone. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report