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

[New Term] C++ Math Functions: round() #1043

Merged
merged 21 commits into from
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 Oct 4, 2022
6895c90
fix: removed unwanted fun `round()` from `main` (#986)
tanishq-singh-2407 Oct 5, 2022
bca068e
New Entry: C++ Math Functions: `round()` (#986)
tanishq-singh-2407 Oct 5, 2022
284e872
fix: sentences rephrased (#986)
tanishq-singh-2407 Oct 5, 2022
63c6fbf
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 Oct 5, 2022
55828c9
:zap: fix: update example and sentences rephrased (#986)
tanishq-singh-2407 Oct 6, 2022
91469eb
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 Oct 6, 2022
5f5a502
:zap: refactor: cpp math-function `round()` (#986)
tanishq-singh-2407 Oct 7, 2022
fbf7010
:zap: refactor: cpp math-function `round()` (#986)
tanishq-singh-2407 Oct 7, 2022
771c271
Merge remote-tracking branch 'refs/remotes/origin/tanishq-singh-round…
tanishq-singh-2407 Oct 7, 2022
b64ce3b
:zap: refactor: cpp math-function `round()` (#986)
tanishq-singh-2407 Oct 7, 2022
238ec91
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 Oct 7, 2022
d4980c3
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 Oct 7, 2022
36eddff
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 Oct 7, 2022
244a7b9
Merge branch 'main' into tanishq-singh-round
tanishq-singh-2407 Oct 8, 2022
18612ae
Merge branch 'Codecademy:main' into tanishq-singh-round
tanishq-singh-2407 Oct 13, 2022
f4e5351
fix: changes and reword sentences
tanishq-singh-2407 Oct 13, 2022
fb20ea2
:rocket: fix: compile time error
tanishq-singh-2407 Oct 17, 2022
757c3b5
:rocket: fix: single line to `list` comment
tanishq-singh-2407 Oct 21, 2022
392672e
Merge branch 'main' into tanishq-singh-round
yangc95 Oct 24, 2022
c5bf18e
Update round.md
Dusch4593 Oct 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: sentences rephrased (#986)
  • Loading branch information
tanishq-singh-2407 committed Oct 5, 2022
commit 284e872a84ddf1cba260441f4d50733540e10eeb
20 changes: 11 additions & 9 deletions content/cpp/concepts/math-functions/terms/round/round.md
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.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: 'Returns the integer 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 the ending zero.'

Subjects:
- 'Computer Science'
Tags:
Expand All @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `round()` function returns the integer that is nearest to the argument, with halfway cases rounded away from zero.
The **`round()`** function returns the integer that closest to the argument, with halfway cases rounded away from zero.


## 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`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use `round()` to round-off `10.89`:
The following example is runnable and rounds the halfway case away from zero:


Expand Down