-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explain how to do arithmetic #345
Conversation
🆗 Pre-flight checks passed 😃This pull request has been checked and contains no modified workflow files, spoofing, or invalid commits. Results of any additional workflows will appear here when they are done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @bkmgit!
I think showing how to do arithmetic is definitely useful, but it might be best to avoid introducing more CLI tools (bc
).
Also, please could you edit your initial comment in this pr to say 'Fixes #344' rather than '#344'? Currently, you've mentioned the open issue this pr will solve, but it hasn't been 'linked' so the issue won't be automatically closed when the pr is merged.
Thanks!
episodes/04-redirection.md
Outdated
or [bc - an arbitrary precsion calculator](https://www.gnu.org/software/bc/manual/html_mono/bc.html) | ||
|
||
|
||
```bash | ||
$ echo "996/4" | bc | ||
``` | ||
|
||
```output | ||
249 | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bc
is useful but I think I would avoid introducing another tool as there is already a lot for people to take in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove bc. Maybe it is better to use printf %.3f%% "$((1000 * 996/4))e-3"
so that some decimal places can be shown? Integer arithmetic might hide an
error since echo "$((997/4))"
gives the same answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably lean towards keeping what you currently have and adding a note that it only handles integer division. I think the syntax for formatting strings with printf
might be confusing for people that are new to it, and it would probably need some more explanation than we have space for here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bkmgit taking another look at this it might be worthwhile keeping bc
but explicitly mentioning in which cases you would want to use this over echo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for you contribution @bkmgit !
Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Auto-generated via {sandpaper} Source : 0de50bd Branch : md-outputs Author : GitHub Actions <actions@github.com> Time : 2024-03-14 09:58:30 +0000 Message : markdown source builds Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Auto-generated via {sandpaper} Source : 0de50bd Branch : md-outputs Author : GitHub Actions <actions@github.com> Time : 2024-03-14 09:58:30 +0000 Message : markdown source builds Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Auto-generated via {sandpaper} Source : 0de50bd Branch : md-outputs Author : GitHub Actions <actions@github.com> Time : 2024-03-14 09:58:30 +0000 Message : markdown source builds Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Auto-generated via {sandpaper} Source : 0de50bd Branch : md-outputs Author : GitHub Actions <actions@github.com> Time : 2024-03-14 09:58:30 +0000 Message : markdown source builds Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Auto-generated via {sandpaper} Source : 0de50bd Branch : md-outputs Author : GitHub Actions <actions@github.com> Time : 2024-03-14 09:58:30 +0000 Message : markdown source builds Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Auto-generated via {sandpaper} Source : 0de50bd Branch : md-outputs Author : GitHub Actions <actions@github.com> Time : 2024-03-14 09:58:30 +0000 Message : markdown source builds Auto-generated via {sandpaper} Source : d057eeb Branch : main Author : Benson Muite <bkmgit@users.noreply.github.com> Time : 2024-03-14 09:57:38 +0000 Message : Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith <paul.j.smith@ucl.ac.uk>
Fixes #344