Init
This commit is contained in:
58
cppdraft/c/math/abs.md
Normal file
58
cppdraft/c/math/abs.md
Normal 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.2 Header <cstdlib> synopsis [cstdlib.syn]") and[<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1 Header <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.7 Integral 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
|
||||
16
cppdraft/c/math/fpclass.md
Normal file
16
cppdraft/c/math/fpclass.md
Normal 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
19
cppdraft/c/math/hypot3.md
Normal 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
51
cppdraft/c/math/lerp.md
Normal 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
53
cppdraft/c/math/rand.md
Normal 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.2 Header <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.10 Data race avoidance"))[.](#3.sentence-2)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
The other random
|
||||
number generation facilities in this document ([[rand]](rand "29.5 Random 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
|
||||
Reference in New Issue
Block a user