-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[New Term] C++ Math Functions: round()
#1043
Merged
Dusch4593
merged 21 commits into
Codecademy:main
from
tanishq-singh-2407:tanishq-singh-round
Oct 24, 2022
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
28b78e6
New Entry: C++ Math Functions: `round()` (#986)
tanishq-singh-2407 6895c90
fix: removed unwanted fun `round()` from `main` (#986)
tanishq-singh-2407 bca068e
New Entry: C++ Math Functions: `round()` (#986)
tanishq-singh-2407 284e872
fix: sentences rephrased (#986)
tanishq-singh-2407 63c6fbf
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 55828c9
:zap: fix: update example and sentences rephrased (#986)
tanishq-singh-2407 91469eb
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 5f5a502
:zap: refactor: cpp math-function `round()` (#986)
tanishq-singh-2407 fbf7010
:zap: refactor: cpp math-function `round()` (#986)
tanishq-singh-2407 771c271
Merge remote-tracking branch 'refs/remotes/origin/tanishq-singh-round…
tanishq-singh-2407 b64ce3b
:zap: refactor: cpp math-function `round()` (#986)
tanishq-singh-2407 238ec91
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 d4980c3
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 36eddff
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 244a7b9
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 18612ae
Merge branch 'Codecademy:main' into tanishq-singh-round
tanishq-singh-2407 f4e5351
fix: changes and reword sentences
tanishq-singh-2407 fb20ea2
:rocket: fix: compile time error
tanishq-singh-2407 757c3b5
:rocket: fix: single line to `list` comment
tanishq-singh-2407 392672e
Merge branch 'main' into tanishq-singh-round
yangc95 c5bf18e
Update round.md
Dusch4593 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: sentences rephrased (#986)
- Loading branch information
commit 284e872a84ddf1cba260441f4d50733540e10eeb
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||
--- | ||||||
Title: 'round()' | ||||||
Description: 'Returns the integral value that is nearest to the argument, with halfway cases rounded away from zero.' | ||||||
Description: 'Returns the integer that is nearest to the argument, with halfway cases rounded away from zero.' | ||||||
Subjects: | ||||||
- 'Computer Science' | ||||||
Tags: | ||||||
|
@@ -12,27 +12,29 @@ CatalogContent: | |||||
- 'paths/computer-science' | ||||||
--- | ||||||
|
||||||
The `round()` function returns the integral value that is nearest to the argument, with halfway cases rounded away from zero. | ||||||
The `round()` function returns the integer that is nearest to the argument, with halfway cases rounded away from zero. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## Syntax | ||||||
|
||||||
The `cmath` library must be added at the top of the file. | ||||||
|
||||||
```cpp | ||||||
std::round(double num); | ||||||
```pseudo | ||||||
round(num); | ||||||
``` | ||||||
|
||||||
Argument must be a `double`/`float`/`long double`, and the return value will be the type of `integer`. | ||||||
The `num` parameter must be a `double`,`float`, or `long double`. The return value will be an integer. | ||||||
Dusch4593 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
## Example | ||||||
|
||||||
Dusch4593 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
```cpp | ||||||
double num, result; | ||||||
double num = 9.23; | ||||||
double result; | ||||||
|
||||||
result = std::round(num); | ||||||
|
||||||
std::cout << "The result is " << result << "!\n"; | ||||||
// Output: The result is 9! | ||||||
``` | ||||||
|
||||||
Dusch4593 marked this conversation as resolved.
Show resolved
Hide resolved
Dusch4593 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
## Codecademy Example | ||||||
## Codebyte Example | ||||||
|
||||||
Use `round()` to round-off `10.89`: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.