<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div style="font-family: Arial; font-size: 10pt;">
<p style="font-size: 10pt; font-family: Arial; margin: 0px;">Interesting...
I was under the impression that bc was unable to do floating
numbers. Probably a false memory or some article I read being
wrong. 😅<br>
</p>
</div>
<div
style="font-size: 10pt; padding-top: 3pt; margin-top: 5pt; border-top: 1pt solid #b5c4df; font-family: Tahoma, sans-serif;"><strong>From:
</strong>KB_SBo [<a class="moz-txt-link-freetext" href="mailto:sbo@linuxgalaxy.org">mailto:sbo@linuxgalaxy.org</a>]<br>
<strong>Sent: </strong>Saturday, May 11, 2024 04:04 AM -04<br>
<strong>To: </strong><a class="moz-txt-link-abbreviated" href="mailto:slackbuilds-users@slackbuilds.org">slackbuilds-users@slackbuilds.org</a><br>
<strong>Subject: </strong>[Slackbuilds-users] Using something
other than bash for rc scripts?<br>
<br>
</div>
<div type="cite"
cite="mid:74f23e22-c04a-4bb0-ba29-9a19df692cf2@linuxgalaxy.org">
<pre wrap="" class="moz-quote-pre">On 5/9/24 13:00, Charadon via SlackBuilds-users wrote:
re: bash
</pre>
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">lack of simple arithmetic
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">For integer arithmetic:
$ declare -i a=2+2
$ echo $a
4
$ let b=9+6 ; echo $b
15
$ echo $((2*5+1))
11
or maybe use
$ expr 2 + 3
5
and if you want to get really fancy, use the bc command for floating
point, functions, loops, and algebra:
$ echo "for(i=1; i<=10; i++) {scale=4;sqrt(i);}" | bc
1
1.4142
1.7320
2.0000
2.2360
2.4494
2.6457
2.8284
3.0000
3.1622
bash shell can indeed do a bit of arithmetic, and more.
-KB
_______________________________________________
SlackBuilds-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:SlackBuilds-users@slackbuilds.org">SlackBuilds-users@slackbuilds.org</a>
<a class="moz-txt-link-freetext" href="https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users">https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users</a>
Archives - <a class="moz-txt-link-freetext" href="https://lists.slackbuilds.org/pipermail/slackbuilds-users/">https://lists.slackbuilds.org/pipermail/slackbuilds-users/</a>
FAQ - <a class="moz-txt-link-freetext" href="https://slackbuilds.org/faq/">https://slackbuilds.org/faq/</a>
</pre>
</div>
</body>
</html>