Skip to content
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

Merged
merged 3 commits into from
Mar 14, 2024
Merged

Explain how to do arithmetic #345

merged 3 commits into from
Mar 14, 2024

Conversation

bkmgit
Copy link
Contributor

@bkmgit bkmgit commented Jul 23, 2023

Fixes #344

@github-actions
Copy link

github-actions bot commented Jul 23, 2023

🆗 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.

github-actions bot pushed a commit that referenced this pull request Aug 7, 2023
Copy link
Contributor

@p-j-smith p-j-smith left a 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!

Comment on lines 245 to 255
or [bc - an arbitrary precsion calculator](https://www.gnu.org/software/bc/manual/html_mono/bc.html)


```bash
$ echo "996/4" | bc
```

```output
249
```

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

@p-j-smith p-j-smith left a 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

episodes/04-redirection.md Outdated Show resolved Hide resolved
@p-j-smith p-j-smith self-requested a review March 14, 2024 09:53
Copy link
Contributor

@p-j-smith p-j-smith left a 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 !

github-actions bot pushed a commit that referenced this pull request Mar 14, 2024
@p-j-smith p-j-smith merged commit d057eeb into datacarpentry:main Mar 14, 2024
3 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 14, 2024
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>
github-actions bot pushed a commit that referenced this pull request Mar 14, 2024
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>
github-actions bot pushed a commit that referenced this pull request Mar 19, 2024
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>
github-actions bot pushed a commit that referenced this pull request Mar 26, 2024
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>
github-actions bot pushed a commit that referenced this pull request Apr 2, 2024
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>
github-actions bot pushed a commit that referenced this pull request Apr 9, 2024
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>
github-actions bot pushed a commit that referenced this pull request Apr 16, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finish bad sequences calculation
2 participants