nstd_sys/core/
fty.rs

1//! Provides functions for examining and operating on floating point types.
2use crate::{NSTDFloat32, NSTDFloat64};
3use nstdapi::nstdapi;
4
5/// Returns the smallest finite value representable by `NSTDFloat32`.
6///
7/// # Returns
8///
9/// `NSTDFloat32 min` - The smallest finite value representable by `NSTDFloat32`.
10///
11/// # Example
12///
13/// ```
14/// use nstd_sys::core::fty::nstd_core_fty_min_f32;
15///
16/// # unsafe {
17/// assert!(nstd_core_fty_min_f32() == f32::MIN);
18/// # }
19/// ```
20#[inline]
21#[nstdapi]
22pub const fn nstd_core_fty_min_f32() -> NSTDFloat32 {
23    NSTDFloat32::MIN
24}
25/// Returns the largest finite value representable by `NSTDFloat32`.
26///
27/// # Returns
28///
29/// `NSTDFloat32 max` - The largest finite value representable by `NSTDFloat32`.
30///
31/// # Example
32///
33/// ```
34/// use nstd_sys::core::fty::nstd_core_fty_max_f32;
35///
36/// # unsafe {
37/// assert!(nstd_core_fty_max_f32() == f32::MAX);
38/// # }
39/// ```
40#[inline]
41#[nstdapi]
42pub const fn nstd_core_fty_max_f32() -> NSTDFloat32 {
43    NSTDFloat32::MAX
44}
45/// Returns the smallest finite value representable by `NSTDFloat64`.
46///
47/// # Returns
48///
49/// `NSTDFloat64 min` - The smallest finite value representable by `NSTDFloat64`.
50///
51/// # Example
52///
53/// ```
54/// use nstd_sys::core::fty::nstd_core_fty_min_f64;
55///
56/// # unsafe {
57/// assert!(nstd_core_fty_min_f64() == f64::MIN);
58/// # }
59/// ```
60#[inline]
61#[nstdapi]
62pub const fn nstd_core_fty_min_f64() -> NSTDFloat64 {
63    NSTDFloat64::MIN
64}
65/// Returns the largest finite value representable by `NSTDFloat64`.
66///
67/// # Returns
68///
69/// `NSTDFloat64 max` - The largest finite value representable by `NSTDFloat64`.
70///
71/// # Example
72///
73/// ```
74/// use nstd_sys::core::fty::nstd_core_fty_max_f64;
75///
76/// # unsafe {
77/// assert!(nstd_core_fty_max_f64() == f64::MAX);
78/// # }
79/// ```
80#[inline]
81#[nstdapi]
82pub const fn nstd_core_fty_max_f64() -> NSTDFloat64 {
83    NSTDFloat64::MAX
84}
85
86/// Returns NaN represented as `NSTDFloat32`.
87///
88/// # Returns
89///
90/// `NSTDFloat32 nan` - NaN represented as `NSTDFloat32`.
91///
92/// # Example
93///
94/// ```
95/// use nstd_sys::core::fty::nstd_core_fty_nan_f32;
96///
97/// # unsafe {
98/// assert!(nstd_core_fty_nan_f32().is_nan());
99/// # }
100/// ```
101#[inline]
102#[nstdapi]
103pub const fn nstd_core_fty_nan_f32() -> NSTDFloat32 {
104    NSTDFloat32::NAN
105}
106/// Returns NaN represented as `NSTDFloat64`.
107///
108/// # Returns
109///
110/// `NSTDFloat64 nan` - NaN represented as `NSTDFloat64`.
111///
112/// # Example
113///
114/// ```
115/// use nstd_sys::core::fty::nstd_core_fty_nan_f64;
116///
117/// # unsafe {
118/// assert!(nstd_core_fty_nan_f64().is_nan());
119/// # }
120/// ```
121#[inline]
122#[nstdapi]
123pub const fn nstd_core_fty_nan_f64() -> NSTDFloat64 {
124    NSTDFloat64::NAN
125}
126
127/// Returns infinity represented as `NSTDFloat32`.
128///
129/// # Returns
130///
131/// `NSTDFloat32 inf` - Infinity represented as `NSTDFloat32`.
132///
133/// # Example
134///
135/// ```
136/// use nstd_sys::core::fty::nstd_core_fty_inf_f32;
137///
138/// # unsafe {
139/// assert!(nstd_core_fty_inf_f32() == f32::INFINITY);
140/// # }
141/// ```
142#[inline]
143#[nstdapi]
144pub const fn nstd_core_fty_inf_f32() -> NSTDFloat32 {
145    NSTDFloat32::INFINITY
146}
147/// Returns infinity represented as `NSTDFloat64`.
148///
149/// # Returns
150///
151/// `NSTDFloat64 inf` - Infinity represented as `NSTDFloat64`.
152///
153/// # Example
154///
155/// ```
156/// use nstd_sys::core::fty::nstd_core_fty_inf_f64;
157///
158/// # unsafe {
159/// assert!(nstd_core_fty_inf_f64() == f64::INFINITY);
160/// # }
161/// ```
162#[inline]
163#[nstdapi]
164pub const fn nstd_core_fty_inf_f64() -> NSTDFloat64 {
165    NSTDFloat64::INFINITY
166}
167
168/// Returns negative infinity represented as `NSTDFloat32`.
169///
170/// # Returns
171///
172/// `NSTDFloat32 neg_inf` - Negative infinity represented as `NSTDFloat32`.
173///
174/// # Example
175///
176/// ```
177/// use nstd_sys::core::fty::nstd_core_fty_neg_inf_f32;
178///
179/// # unsafe {
180/// assert!(nstd_core_fty_neg_inf_f32() == f32::NEG_INFINITY);
181/// # }
182/// ```
183#[inline]
184#[nstdapi]
185pub const fn nstd_core_fty_neg_inf_f32() -> NSTDFloat32 {
186    NSTDFloat32::NEG_INFINITY
187}
188/// Returns negative infinity represented as `NSTDFloat64`.
189///
190/// # Returns
191///
192/// `NSTDFloat64 neg_inf` - Negative infinity represented as `NSTDFloat64`.
193///
194/// # Example
195///
196/// ```
197/// use nstd_sys::core::fty::nstd_core_fty_neg_inf_f64;
198///
199/// # unsafe {
200/// assert!(nstd_core_fty_neg_inf_f64() == f64::NEG_INFINITY);
201/// # }
202/// ```
203#[inline]
204#[nstdapi]
205pub const fn nstd_core_fty_neg_inf_f64() -> NSTDFloat64 {
206    NSTDFloat64::NEG_INFINITY
207}