From eeaa0ca54f70891dbff70170a66ebc6bdeba2d9b Mon Sep 17 00:00:00 2001 From: kentgabmagbuhat-oss Date: Fri, 14 Nov 2025 12:53:42 +1300 Subject: [PATCH 1/7] Create isgreater.md --- .../terms/isgreater/isgreater.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 content/cpp/concepts/math-functions /terms/isgreater/isgreater.md diff --git a/content/cpp/concepts/math-functions /terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions /terms/isgreater/isgreater.md new file mode 100644 index 00000000000..86a1fd46492 --- /dev/null +++ b/content/cpp/concepts/math-functions /terms/isgreater/isgreater.md @@ -0,0 +1,87 @@ +--- +Title: 'isgreater()' +Description: 'Compares two floating-point values and returns true if the first is strictly greater than the second.' +Subjects: + - 'Computer Science' +Tags: + - 'Math' + - 'Functions' + - 'Comparison' +CatalogContent: + - 'learn-c-plus-plus' + - 'paths/computer-science' +--- + +The **`isgreater()`** function performs a strict greater-than comparison between two floating-point values and returns `true` only if the first argument is greater than the second. Unlike the regular `>` operator, `isgreater()` never raises floating-point exceptions and always returns `false` when either argument is NaN (Not-a-Number). + +## Syntax + +``` +isgreater(x, y) +``` +### Parameters +x, y: Arithmetic values (integers or floating-point types). + +Integer arguments are promoted to the appropriate floating-point type. + +### Return Value +true if x > y and neither argument is NaN. + +false otherwise — including if either value is NaN. + +### Key Behavior +Quiet comparison: does not raise floating-point exceptions (e.g., FE_INVALID). + +isgreater(NaN, y) and isgreater(x, NaN) always return false. + +Follows IEEE-754 comparison semantics. + +Available through the header in C++. + +## Example +Use `isgreater()` to check if one number is greater than another: +``` +#include +#include + +int main() { + double x = 10.5; + double y = 5.2; + double z = std::nan("1"); + + std::cout << std::boolalpha; + + std::cout << "isgreater(x, y): " + << std::isgreater(x, y) << std::endl; + + std::cout << "isgreater(x, z): " + << std::isgreater(x, z) << " (NaN comparison)" << std::endl; + + return 0; +} +``` + +### Output +``` +isgreater(x, y): true +isgreater(x, z): false (NaN comparison) +``` + +## Codebyte Example +The following example is runnable and outputs whether one number is greater than another using `isgreater()`: +``` +#include +#include +using namespace std; + +int main() { + double a = 7.5; + double b = 9.3; + + cout << boolalpha; + cout << "isgreater(a, b): " << isgreater(a, b) << endl; + cout << "isgreater(b, a): " << isgreater(b, a) << endl; + + return 0; +} +``` From 007213799f8c88e883c1b1e629bed2cdbe629631 Mon Sep 17 00:00:00 2001 From: kentgabmagbuhat-oss Date: Fri, 14 Nov 2025 13:03:51 +1300 Subject: [PATCH 2/7] Create isgreater.md --- .../terms/isgreater/isgreater.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 content/cpp/concepts/math-functions/terms/isgreater/isgreater.md diff --git a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md new file mode 100644 index 00000000000..86a1fd46492 --- /dev/null +++ b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md @@ -0,0 +1,87 @@ +--- +Title: 'isgreater()' +Description: 'Compares two floating-point values and returns true if the first is strictly greater than the second.' +Subjects: + - 'Computer Science' +Tags: + - 'Math' + - 'Functions' + - 'Comparison' +CatalogContent: + - 'learn-c-plus-plus' + - 'paths/computer-science' +--- + +The **`isgreater()`** function performs a strict greater-than comparison between two floating-point values and returns `true` only if the first argument is greater than the second. Unlike the regular `>` operator, `isgreater()` never raises floating-point exceptions and always returns `false` when either argument is NaN (Not-a-Number). + +## Syntax + +``` +isgreater(x, y) +``` +### Parameters +x, y: Arithmetic values (integers or floating-point types). + +Integer arguments are promoted to the appropriate floating-point type. + +### Return Value +true if x > y and neither argument is NaN. + +false otherwise — including if either value is NaN. + +### Key Behavior +Quiet comparison: does not raise floating-point exceptions (e.g., FE_INVALID). + +isgreater(NaN, y) and isgreater(x, NaN) always return false. + +Follows IEEE-754 comparison semantics. + +Available through the header in C++. + +## Example +Use `isgreater()` to check if one number is greater than another: +``` +#include +#include + +int main() { + double x = 10.5; + double y = 5.2; + double z = std::nan("1"); + + std::cout << std::boolalpha; + + std::cout << "isgreater(x, y): " + << std::isgreater(x, y) << std::endl; + + std::cout << "isgreater(x, z): " + << std::isgreater(x, z) << " (NaN comparison)" << std::endl; + + return 0; +} +``` + +### Output +``` +isgreater(x, y): true +isgreater(x, z): false (NaN comparison) +``` + +## Codebyte Example +The following example is runnable and outputs whether one number is greater than another using `isgreater()`: +``` +#include +#include +using namespace std; + +int main() { + double a = 7.5; + double b = 9.3; + + cout << boolalpha; + cout << "isgreater(a, b): " << isgreater(a, b) << endl; + cout << "isgreater(b, a): " << isgreater(b, a) << endl; + + return 0; +} +``` From 351e6e3897c6736ec6a42d847eba8e057ec1d951 Mon Sep 17 00:00:00 2001 From: kentgabmagbuhat-oss Date: Fri, 14 Nov 2025 13:07:46 +1300 Subject: [PATCH 3/7] Delete content/cpp/concepts/math-functions directory --- .../terms/isgreater/isgreater.md | 87 ------------------- 1 file changed, 87 deletions(-) delete mode 100644 content/cpp/concepts/math-functions /terms/isgreater/isgreater.md diff --git a/content/cpp/concepts/math-functions /terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions /terms/isgreater/isgreater.md deleted file mode 100644 index 86a1fd46492..00000000000 --- a/content/cpp/concepts/math-functions /terms/isgreater/isgreater.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -Title: 'isgreater()' -Description: 'Compares two floating-point values and returns true if the first is strictly greater than the second.' -Subjects: - - 'Computer Science' -Tags: - - 'Math' - - 'Functions' - - 'Comparison' -CatalogContent: - - 'learn-c-plus-plus' - - 'paths/computer-science' ---- - -The **`isgreater()`** function performs a strict greater-than comparison between two floating-point values and returns `true` only if the first argument is greater than the second. Unlike the regular `>` operator, `isgreater()` never raises floating-point exceptions and always returns `false` when either argument is NaN (Not-a-Number). - -## Syntax - -``` -isgreater(x, y) -``` -### Parameters -x, y: Arithmetic values (integers or floating-point types). - -Integer arguments are promoted to the appropriate floating-point type. - -### Return Value -true if x > y and neither argument is NaN. - -false otherwise — including if either value is NaN. - -### Key Behavior -Quiet comparison: does not raise floating-point exceptions (e.g., FE_INVALID). - -isgreater(NaN, y) and isgreater(x, NaN) always return false. - -Follows IEEE-754 comparison semantics. - -Available through the header in C++. - -## Example -Use `isgreater()` to check if one number is greater than another: -``` -#include -#include - -int main() { - double x = 10.5; - double y = 5.2; - double z = std::nan("1"); - - std::cout << std::boolalpha; - - std::cout << "isgreater(x, y): " - << std::isgreater(x, y) << std::endl; - - std::cout << "isgreater(x, z): " - << std::isgreater(x, z) << " (NaN comparison)" << std::endl; - - return 0; -} -``` - -### Output -``` -isgreater(x, y): true -isgreater(x, z): false (NaN comparison) -``` - -## Codebyte Example -The following example is runnable and outputs whether one number is greater than another using `isgreater()`: -``` -#include -#include -using namespace std; - -int main() { - double a = 7.5; - double b = 9.3; - - cout << boolalpha; - cout << "isgreater(a, b): " << isgreater(a, b) << endl; - cout << "isgreater(b, a): " << isgreater(b, a) << endl; - - return 0; -} -``` From e8e0557ccfa9606b1731e934352a2d50ded0c3c5 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Fri, 14 Nov 2025 11:30:01 +0530 Subject: [PATCH 4/7] minor content fixes --- .../terms/isgreater/isgreater.md | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md index 86a1fd46492..5d518e13781 100644 --- a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md +++ b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md @@ -3,10 +3,12 @@ Title: 'isgreater()' Description: 'Compares two floating-point values and returns true if the first is strictly greater than the second.' Subjects: - 'Computer Science' + - 'Data Science' + - 'Game Development' Tags: - - 'Math' - 'Functions' - 'Comparison' + - 'Math' CatalogContent: - 'learn-c-plus-plus' - 'paths/computer-science' @@ -14,74 +16,71 @@ CatalogContent: The **`isgreater()`** function performs a strict greater-than comparison between two floating-point values and returns `true` only if the first argument is greater than the second. Unlike the regular `>` operator, `isgreater()` never raises floating-point exceptions and always returns `false` when either argument is NaN (Not-a-Number). +The **`isgreater()`** function compares two floating-point values and returns `true` only when the first is strictly greater than the second. It follows IEEE-754 rules, never raises floating-point exceptions, and always returns false if either argument is `NaN`. Integer inputs are promoted to floating-point. The function is available through the `` header. + ## Syntax -``` +```pseudo isgreater(x, y) ``` -### Parameters -x, y: Arithmetic values (integers or floating-point types). - -Integer arguments are promoted to the appropriate floating-point type. -### Return Value -true if x > y and neither argument is NaN. +**Parameters:** -false otherwise — including if either value is NaN. +- `x`, `y`: Arithmetic values (integers or floating-point types). -### Key Behavior -Quiet comparison: does not raise floating-point exceptions (e.g., FE_INVALID). +Integer arguments are promoted to the appropriate floating-point type. -isgreater(NaN, y) and isgreater(x, NaN) always return false. +**Return value:** -Follows IEEE-754 comparison semantics. +The `isgreater()` function returns: -Available through the header in C++. +- `true` if `x > y` and neither argument is `NaN` +- `false` otherwise, including when either value is `NaN` ## Example -Use `isgreater()` to check if one number is greater than another: -``` + +The following example checks whether one number is greater than another, including a comparison involving `NaN`: + +```cpp #include #include int main() { - double x = 10.5; - double y = 5.2; - double z = std::nan("1"); - - std::cout << std::boolalpha; - - std::cout << "isgreater(x, y): " - << std::isgreater(x, y) << std::endl; - - std::cout << "isgreater(x, z): " - << std::isgreater(x, z) << " (NaN comparison)" << std::endl; - - return 0; + double x = 10.5; + double y = 5.2; + double z = std::nan("1"); + + std::cout << std::boolalpha; + std::cout << "isgreater(x, y): " << std::isgreater(x, y) << std::endl; + std::cout << "isgreater(x, z): " << std::isgreater(x, z) << " (NaN comparison)" << std::endl; + return 0; } ``` -### Output -``` +The output of this code is as follows: + +```shell isgreater(x, y): true isgreater(x, z): false (NaN comparison) ``` ## Codebyte Example + The following example is runnable and outputs whether one number is greater than another using `isgreater()`: -``` + +```codebyte/cpp #include #include using namespace std; int main() { - double a = 7.5; - double b = 9.3; + double a = 7.5; + double b = 9.3; - cout << boolalpha; - cout << "isgreater(a, b): " << isgreater(a, b) << endl; - cout << "isgreater(b, a): " << isgreater(b, a) << endl; + cout << boolalpha; + cout << "isgreater(a, b): " << isgreater(a, b) << endl; + cout << "isgreater(b, a): " << isgreater(b, a) << endl; - return 0; + return 0; } ``` From d494700d9e7864a61aff1142b1342a4641ca7482 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Fri, 14 Nov 2025 11:31:07 +0530 Subject: [PATCH 5/7] Update isgreater.md --- .../cpp/concepts/math-functions/terms/isgreater/isgreater.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md index 5d518e13781..fbb6a4aaac9 100644 --- a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md +++ b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md @@ -14,9 +14,7 @@ CatalogContent: - 'paths/computer-science' --- -The **`isgreater()`** function performs a strict greater-than comparison between two floating-point values and returns `true` only if the first argument is greater than the second. Unlike the regular `>` operator, `isgreater()` never raises floating-point exceptions and always returns `false` when either argument is NaN (Not-a-Number). - -The **`isgreater()`** function compares two floating-point values and returns `true` only when the first is strictly greater than the second. It follows IEEE-754 rules, never raises floating-point exceptions, and always returns false if either argument is `NaN`. Integer inputs are promoted to floating-point. The function is available through the `` header. +The **`isgreater()`** [function](https://www.codecademy.com/resources/docs/cpp/functions) compares two floating-point values and returns `true` only when the first is strictly greater than the second. It follows IEEE-754 rules, never raises floating-point exceptions, and always returns `false` if either argument is `NaN`. Integer inputs are promoted to floating-point. The function is available through the `` header. ## Syntax From 80df7dacbef029ccb5efdd5bb7d9429288e0253e Mon Sep 17 00:00:00 2001 From: Daksha Deep Date: Wed, 19 Nov 2025 17:04:40 +0530 Subject: [PATCH 6/7] Update isgreater.md --- .../cpp/concepts/math-functions/terms/isgreater/isgreater.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md index fbb6a4aaac9..ec7d21fd7d6 100644 --- a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md +++ b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md @@ -26,7 +26,7 @@ isgreater(x, y) - `x`, `y`: Arithmetic values (integers or floating-point types). -Integer arguments are promoted to the appropriate floating-point type. +> **Note:** Integer arguments are promoted to the appropriate floating-point type. **Return value:** From de7e4590823d3806bc42ccc72cb88a308a94f971 Mon Sep 17 00:00:00 2001 From: Daksha Deep Date: Wed, 19 Nov 2025 17:13:39 +0530 Subject: [PATCH 7/7] Update isgreater.md --- .../math-functions/terms/isgreater/isgreater.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md index ec7d21fd7d6..f78dea9416a 100644 --- a/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md +++ b/content/cpp/concepts/math-functions/terms/isgreater/isgreater.md @@ -41,16 +41,20 @@ The following example checks whether one number is greater than another, includi ```cpp #include +#include #include +using namespace std; + int main() { double x = 10.5; double y = 5.2; - double z = std::nan("1"); + double z = nan("1"); + + cout << boolalpha; + cout << "isgreater(x, y): " << isgreater(x, y) << endl; + cout << "isgreater(x, z): " << isgreater(x, z) << " (NaN comparison)" << endl; - std::cout << std::boolalpha; - std::cout << "isgreater(x, y): " << std::isgreater(x, y) << std::endl; - std::cout << "isgreater(x, z): " << std::isgreater(x, z) << " (NaN comparison)" << std::endl; return 0; } ```