From 2916892843975eb08d968d44fc6e03a02c600e75 Mon Sep 17 00:00:00 2001 From: Cadilhe Date: Sun, 30 Nov 2025 11:31:24 +0000 Subject: [PATCH 1/2] [term entry] C++ math-functions: isgreaterequal() --- .../terms/isgreaterequal/isgreaterequal.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md diff --git a/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md b/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md new file mode 100644 index 00000000000..a060f8836a9 --- /dev/null +++ b/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md @@ -0,0 +1,89 @@ +--- +Title: 'isgreaterequal()' +Description: 'Determines if the floating-point number `x` is greater than or equal to the floating-point number `y`, without setting floating-point exceptions.' +Subjects: + +Tags: + - 'Functions' + - 'Comparison' + - 'Math' +CatalogContent: + - 'learn-c-plus-plus' +--- + +The **`isgreaterequal()`** [function](https://www.codecademy.com/resources/docs/cpp/functions) compares two floating-point values and returns `true` only when the first is greater than or equal to the second. Never raises floating-point exceptions, and always returns `false` if one or both arguments is `NaN`. The function is available through the `` header. + +## Syntax + +``` +isgreaterequal(x, y) +``` + +**Parameters:** + +- `x`, `y`: floating-point or integers types. + + +> **Notes:** +> + The function `isgreaterequal()`is defined with overloads so it works with any mix of arithmetic values. +> + The built-in operator>= for floating-point numbers may raise `FE_INVALID` if one or both of the arguments is NaN. The function `isgreaterequal()` is a "quiet" version of operator>=. + +**Return value:** + +The `isgreaterequal()` function returns: + +- `true` if `x >= y` and neither argument is `NaN` +- `false` otherwise, including when either value is `NaN` + +## Example + +The following example checks whether one number is greater than another, including a comparison involving `NaN`: + +```cpp +#include +#include + +using namespace std; + +int main() { + float x = 5.5; + int y = 3; + double z = nan("1"); + + cout << boolalpha; + cout << x << " isgreaterequal to " << y << ": " << isgreaterequal(x, y) << endl; + cout << y << " isgreaterequal to " << x << ": " << isgreaterequal(y, x) << endl; + cout << x << " isgreaterequal to " << z << ": " << isgreaterequal(x, z) << " (NaN comparison)" << endl; + + return 0; +} +``` + +The output of this code is as follows: + +```shell +5.5 isgreaterequal to 3: true +3 isgreaterequal to 5.5: false +5.5 isgreaterequal to nan: false +``` + +## Codebyte Example + +The following example is runnable and outputs whether one number is greater than or equal to another using `isgreaterequal()`: + +```codebyte/cpp +#include +#include +using namespace std; + +int main() { + float a = 2.5; + float b = 7.3; + + cout << boolalpha; + cout << a << " isgreaterequal to " << b << ": " << isgreaterequal(a, b) << endl; + cout << b << " isgreaterequal to " << a << ": " << isgreaterequal(b, a) << endl; + + return 0; +} +``` From a4d1219d58799a7dd372a9262a1c1142d135c7b9 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Fri, 5 Dec 2025 11:33:16 +0530 Subject: [PATCH 2/2] Refine isgreaterequal() documentation Updated the description and notes for clarity and accuracy. --- .../terms/isgreaterequal/isgreaterequal.md | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md b/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md index a060f8836a9..71349d188e4 100644 --- a/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md +++ b/content/cpp/concepts/math-functions/terms/isgreaterequal/isgreaterequal.md @@ -1,32 +1,33 @@ --- Title: 'isgreaterequal()' -Description: 'Determines if the floating-point number `x` is greater than or equal to the floating-point number `y`, without setting floating-point exceptions.' +Description: 'Determines whether the first floating-point value is greater than or equal to the second, without raising floating-point exceptions.' Subjects: - + - 'Computer Science' + - 'Game Development' Tags: - 'Functions' - - 'Comparison' - 'Math' CatalogContent: - 'learn-c-plus-plus' + - 'paths/computer-science' --- -The **`isgreaterequal()`** [function](https://www.codecademy.com/resources/docs/cpp/functions) compares two floating-point values and returns `true` only when the first is greater than or equal to the second. Never raises floating-point exceptions, and always returns `false` if one or both arguments is `NaN`. The function is available through the `` header. +The **`isgreaterequal()`** [function](https://www.codecademy.com/resources/docs/cpp/functions) compares two arithmetic values and returns `true` only when the first is greater than or equal to the second. It never raises floating-point exceptions and always returns `false` if either argument is `NaN`. The function is available through the `` header. ## Syntax -``` +```pseudo isgreaterequal(x, y) ``` **Parameters:** -- `x`, `y`: floating-point or integers types. - +- `x`, `y`: Floating-point or integers types. -> **Notes:** -> + The function `isgreaterequal()`is defined with overloads so it works with any mix of arithmetic values. -> + The built-in operator>= for floating-point numbers may raise `FE_INVALID` if one or both of the arguments is NaN. The function `isgreaterequal()` is a "quiet" version of operator>=. +> **Notes:** +> +> - The function `isgreaterequal()` is defined with overloads so it works with any mix of arithmetic values. +> - The built-in operator `>=` for floating-point numbers may raise `FE_INVALID` if one or both of the arguments is `NaN`. The function `isgreaterequal()` is a "quiet" version of operator `>=`. **Return value:** @@ -64,7 +65,7 @@ The output of this code is as follows: ```shell 5.5 isgreaterequal to 3: true 3 isgreaterequal to 5.5: false -5.5 isgreaterequal to nan: false +5.5 isgreaterequal to nan: false (NaN comparison) ``` ## Codebyte Example