mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
Domain of sqrt() is nonnegative numbers, not positive.
This commit is contained in:
@@ -1060,9 +1060,9 @@ Obviously, we cannot catch all errors through the static type system
|
|||||||
|
|
||||||
double sqrt(double x);
|
double sqrt(double x);
|
||||||
|
|
||||||
Here `x` must be positive. The type system cannot (easily and naturally) express that, so we must use other means. For example:
|
Here `x` must be nonnegative. The type system cannot (easily and naturally) express that, so we must use other means. For example:
|
||||||
|
|
||||||
double sqrt(double x); // x must be positive
|
double sqrt(double x); // x must be nonnegative
|
||||||
|
|
||||||
Some preconditions can be expressed as assertions. For example:
|
Some preconditions can be expressed as assertions. For example:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user