This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

58
cppdraft/c/math/abs.md Normal file
View File

@@ -0,0 +1,58 @@
[c.math.abs]
# 29 Numerics library [[numerics]](./#numerics)
## 29.7 Mathematical functions for floating-point types [[c.math]](c.math#abs)
### 29.7.2 Absolute values [c.math.abs]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9843)
[*Note [1](#note-1)*:
The headers [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") and[<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") declare the functions described in this subclause[.](#1.sentence-1)
— *end note*]
[🔗](#lib:abs)
`constexpr int abs(int j);
constexpr long int abs(long int j);
constexpr long long int abs(long long int j);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9858)
*Effects*: These
functions have the semantics specified in the C standard library
for the functions abs, labs, and llabs, respectively[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9864)
*Remarks*: If abs is called with an argument of type X for which is_unsigned_v<X> is true and
if X cannot be converted to int by [integral promotion](conv.prom "7.3.7Integral promotions[conv.prom]"), the program is ill-formed[.](#3.sentence-1)
[*Note [2](#note-2)*:
Allowing arguments that can be promoted to int provides compatibility with C[.](#3.sentence-2)
— *end note*]
[🔗](#itemdecl:2)
`constexpr floating-point-type abs(floating-point-type x);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9881)
*Returns*: The absolute value of x[.](#4.sentence-1)
See also: ISO/IEC 9899:2024, 7.12.7.2, 7.22.6.1

View File

@@ -0,0 +1,16 @@
[c.math.fpclass]
# 29 Numerics library [[numerics]](./#numerics)
## 29.7 Mathematical functions for floating-point types [[c.math]](c.math#fpclass)
### 29.7.5 Classification / comparison functions [c.math.fpclass]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9936)
The classification / comparison functions behave the same as the C macros with the
corresponding names defined in the C standard library[.](#1.sentence-1)
See also: ISO/IEC 9899:2024, 7.12.3, 7.12.4

19
cppdraft/c/math/hypot3.md Normal file
View File

@@ -0,0 +1,19 @@
[c.math.hypot3]
# 29 Numerics library [[numerics]](./#numerics)
## 29.7 Mathematical functions for floating-point types [[c.math]](c.math#hypot3)
### 29.7.3 Three-dimensional hypotenuse [c.math.hypot3]
[🔗](#lib:hypot,3-argument_form)
`constexpr floating-point-type hypot(floating-point-type x, floating-point-type y,
floating-point-type z);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9897)
*Returns*: √x2+y2+z2[.](#1.sentence-1)

51
cppdraft/c/math/lerp.md Normal file
View File

@@ -0,0 +1,51 @@
[c.math.lerp]
# 29 Numerics library [[numerics]](./#numerics)
## 29.7 Mathematical functions for floating-point types [[c.math]](c.math#lerp)
### 29.7.4 Linear interpolation [c.math.lerp]
[🔗](#lib:lerp)
`constexpr floating-point-type lerp(floating-point-type a, floating-point-type b,
floating-point-type t) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9910)
*Returns*: a+t(b−a)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9914)
*Remarks*: Let r be the value returned[.](#2.sentence-1)
If isfinite(a) && isfinite(b), then:
- [(2.1)](#2.1)
If t == 0, then r == a[.](#2.1.sentence-1)
- [(2.2)](#2.2)
If t == 1, then r == b[.](#2.2.sentence-1)
- [(2.3)](#2.3)
If t >= 0 && t <= 1, then isfinite(r)[.](#2.3.sentence-1)
- [(2.4)](#2.4)
If isfinite(t) && a == b, then r == a[.](#2.4.sentence-1)
- [(2.5)](#2.5)
If isfinite(t) || !isnan(t) && b - a != 0, then !isnan(r)[.](#2.5.sentence-1)
Let *CMP*(x,y) be 1 if x > y,-1 if x < y, and 0 otherwise[.](#2.sentence-3)
For any t1 and t2, the product of*CMP*(lerp(a, b, t2), lerp(a, b, t1)),*CMP*(t2, t1), and*CMP*(b, a) is non-negative[.](#2.sentence-4)

53
cppdraft/c/math/rand.md Normal file
View File

@@ -0,0 +1,53 @@
[c.math.rand]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#c.math.rand)
### 29.5.10 Low-quality random number generation [c.math.rand]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6923)
[*Note [1](#note-1)*:
The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") declares the functions described in this subclause[.](#1.sentence-1)
— *end note*]
[🔗](#lib:rand)
`int rand();
void srand(unsigned int seed);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6937)
*Effects*: Therand and srand functions have the semantics specified in the C standard library[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6943)
*Remarks*: The implementation
may specify that particular library functions may callrand[.](#3.sentence-1)
It is implementation-defined
whether the rand function
may introduce data races ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance"))[.](#3.sentence-2)
[*Note [2](#note-2)*:
The other random
number generation facilities in this document ([[rand]](rand "29.5Random number generation")) are often preferable
to rand, because rand's underlying algorithm is unspecified[.](#3.sentence-3)
Use of rand therefore continues to be non-portable, with unpredictable
and oft-questionable quality and performance[.](#3.sentence-4)
— *end note*]
See also: ISO/IEC 9899:2024, 7.22.2