devela/num/float/
constants.rs
1#![allow(clippy::excessive_precision)]
17
18use crate::Float; #[cfg(feature = "nightly_float")]
21use ::core::{f128, f16};
22
23#[doc = crate::TAG_NAMESPACE!()]
24#[rustfmt::skip]
154pub trait ExtFloatConst: Sized {
155 #[doc = ONE!()] const ONE: Self;
157 #[doc = ZERO!()] const ZERO: Self;
158 #[doc = NEG_ONE!()] const NEG_ONE: Self;
159 #[doc = NEG_ZERO!()] const NEG_ZERO: Self;
160 #[doc = NAN!()] const NAN: Self;
162 #[doc = INFINITY!()] const INFINITY: Self;
163 #[doc = NEG_INFINITY!()] const NEG_INFINITY: Self;
164 #[doc = MIN!()] const MIN: Self;
165 #[doc = MIN_POSITIVE!()] const MIN_POSITIVE: Self;
166 #[doc = MAX!()] const MAX: Self;
167 #[doc = MIN_EXP!()] const MIN_EXP: i32;
168 #[doc = MAX_EXP!()] const MAX_EXP: i32;
169 #[doc = MIN_10_EXP!()] const MIN_10_EXP: i32;
170 #[doc = MAX_10_EXP!()] const MAX_10_EXP: i32;
171 #[doc = EPSILON!()] const EPSILON: Self;
172 #[doc = LOW_MARGIN!()] const LOW_MARGIN: Self;
173 #[doc = MEDIUM_MARGIN!()] const MEDIUM_MARGIN: Self;
174 #[doc = HIGH_MARGIN!()] const HIGH_MARGIN: Self;
175 #[doc = RADIX!()] const RADIX: u32;
176 #[doc = DIGITS!()] const DIGITS: u32;
177 #[doc = MANTISSA_DIGITS!()] const MANTISSA_DIGITS: u32;
178 #[doc = SIGNIFICAND_BITS!()] const SIGNIFICAND_BITS: u32;
179 #[doc = EXPONENT_BIAS!()] const EXPONENT_BIAS: u32;
180 #[doc = EXPONENT_BITS!()] const EXPONENT_BITS: u32;
181 #[doc = PI!()] const PI: Self;
183 #[doc = FRAC_PI_2!()] const FRAC_PI_2: Self;
184 #[doc = FRAC_PI_3!()] const FRAC_PI_3: Self;
185 #[doc = FRAC_PI_4!()] const FRAC_PI_4: Self;
186 #[doc = FRAC_PI_6!()] const FRAC_PI_6: Self;
187 #[doc = FRAC_PI_8!()] const FRAC_PI_8: Self;
188 #[doc = SQRT_PI!()] const SQRT_PI: Self;
189 #[doc = FRAC_1_PI!()] const FRAC_1_PI: Self;
190 #[doc = FRAC_1_SQRT_PI!()] const FRAC_1_SQRT_PI: Self;
191 #[doc = FRAC_1_SQRT_2PI!()] const FRAC_1_SQRT_2PI: Self;
192 #[doc = FRAC_2_PI!()] const FRAC_2_PI: Self;
193 #[doc = FRAC_2_SQRT_PI!()] const FRAC_2_SQRT_PI: Self;
194 #[doc = TAU!()] const TAU: Self;
196 #[doc = FRAC_TAU_2!()] const FRAC_TAU_2: Self;
197 #[doc = FRAC_TAU_3!()] const FRAC_TAU_3: Self;
198 #[doc = FRAC_TAU_4!()] const FRAC_TAU_4: Self;
199 #[doc = FRAC_TAU_5!()] const FRAC_TAU_5: Self;
200 #[doc = FRAC_TAU_6!()] const FRAC_TAU_6: Self;
201 #[doc = FRAC_TAU_8!()] const FRAC_TAU_8: Self;
202 #[doc = FRAC_TAU_9!()] const FRAC_TAU_9: Self;
203 #[doc = FRAC_TAU_12!()] const FRAC_TAU_12: Self;
204 #[doc = FRAC_TAU_16!()] const FRAC_TAU_16: Self;
205 #[doc = FRAC_TAU_24!()] const FRAC_TAU_24: Self;
206 #[doc = FRAC_TAU_72!()] const FRAC_TAU_72: Self;
207 #[doc = FRAC_TAU_360!()] const FRAC_TAU_360: Self;
208 #[doc = FRAC_360_TAU!()] const FRAC_360_TAU: Self;
209 #[doc = SQRT_TAU!()] const SQRT_TAU: Self;
210 #[doc = FRAC_1_TAU!()] const FRAC_1_TAU: Self;
211 #[doc = FRAC_1_SQRT_TAU!()] const FRAC_1_SQRT_TAU: Self;
212 #[doc = FRAC_2_TAU!()] const FRAC_2_TAU: Self;
213 #[doc = FRAC_2_SQRT_TAU!()] const FRAC_2_SQRT_TAU: Self;
214 #[doc = ARC_DEGREE!()] const ARC_DEGREE: Self;
216 #[doc = ARC_MINUTE!()] const ARC_MINUTE: Self;
217 #[doc = ARC_SECOND!()] const ARC_SECOND: Self;
218 #[doc = PHI!()] const PHI: Self;
220 #[doc = SQ_PHI!()] const SQ_PHI: Self;
221 #[doc = FRAC_1_PHI!()] const FRAC_1_PHI: Self;
222 #[doc = NEG_FRAC_1_PHI!()] const NEG_FRAC_1_PHI: Self;
223 #[doc = SQRT_PHI!()] const SQRT_PHI: Self;
224 #[doc = FRAC_1_SQRT_PHI!()] const FRAC_1_SQRT_PHI: Self;
225 #[doc = TRIBONACCI!()] const TRIBONACCI: Self;
226 #[doc = SQRT_2!()] const SQRT_2: Self;
228 #[doc = FRAC_1_SQRT_2!()] const FRAC_1_SQRT_2: Self;
229 #[doc = SQRT_3!()] const SQRT_3: Self;
230 #[doc = FRAC_1_SQRT_3!()] const FRAC_1_SQRT_3: Self;
231 #[doc = SQRT_5!()] const SQRT_5: Self;
232 #[doc = SQRT_6!()] const SQRT_6: Self;
233 #[doc = SQRT_7!()] const SQRT_7: Self;
234 #[doc = SQRT_8!()] const SQRT_8: Self;
235 #[doc = SQRT_10!()] const SQRT_10: Self;
236 #[doc = SQRT_11!()] const SQRT_11: Self;
237 #[doc = SQRT_12!()] const SQRT_12: Self;
238 #[doc = CBRT_2!()] const CBRT_2: Self;
239 #[doc = CBRT_3!()] const CBRT_3: Self;
240 #[doc = FRAC_1_CBRT_3!()] const FRAC_1_CBRT_3: Self;
241 #[doc = E!()] const E: Self;
243 #[doc = EGAMMA!()] const EGAMMA: Self;
244 #[doc = LOG2_E!()] const LOG2_E: Self;
245 #[doc = LOG2_10!()] const LOG2_10: Self;
246 #[doc = LOG10_E!()] const LOG10_E: Self;
247 #[doc = LOG10_2!()] const LOG10_2: Self;
248 #[doc = LN_2!()] const LN_2: Self;
249 #[doc = LN_10!()] const LN_10: Self;
250}
251
252crate::CONST! { pub(in crate::num::float),
254 ONE = r#"The multiplicative identity 1."#;
256 ZERO = r#"The additive identity 0."#;
257 NEG_ONE = r#"The negative of the multiplicative identity -1."#;
258 NEG_ZERO = r#"The negative of the additive identity -0."#;
259
260 NAN = r#"Not a Number (NaN)."#;
262 INFINITY = r#"Infinity (∞)."#;
263 NEG_INFINITY = r#"Negative infinity (-∞)."#;
264 MIN = r#"Smallest finite value."#;
265 MIN_POSITIVE = r#"Smallest positive normal value."#;
266 MAX = r#"Largest finite value."#;
267 MIN_EXP = r#"One greater than the minimum possible normal power of 2 exponent."#;
268 MAX_EXP = r#"Maximum possible power of 2 exponent."#;
269 MIN_10_EXP = r#"Minimum *x* for which 10<sup>*x*</sup> is normal."#;
270 MAX_10_EXP = r#"Maximum *x* for which 10<sup>*x*</sup> is normal."#;
271 EPSILON = r#"Machine epsilon value.
272 <p>This is the smallest difference detectable between 1.0 and the next
273 representable number in the floating-point format.</p>"#;
274 LOW_MARGIN = r#"Allows for minimal deviation; use for high precision needs.."#;
275 MEDIUM_MARGIN = r#"Accommodates moderate deviation; balances precision and flexibility."#;
276 HIGH_MARGIN = r#"Permits generous deviation; suitable for less precise scenarios."#;
277 RADIX = r#"The radix or base of the internal representation."#;
278 DIGITS = r#"Approximate number of significant digits in base 10."#;
279 MANTISSA_DIGITS = r#"Number of significant digits in base 2."#;
280 SIGNIFICAND_BITS = "Number of explicit bits used to represent the significand (or mantissa).";
281 EXPONENT_BIAS = r#"Exponent bias for representing both positive and negative exponents."#;
282 EXPONENT_BITS = r#"Number of bits used to represent the exponent."#;
283
284 PI = r#"$ π = \frac{1}{2} τ = 180º $
286 ([A000796](https://oeis.org/A000796/constant))
287 `≈ 3.14159265…`
288 <p>*The ratio of the circumference to the diameter, a half-turn*.</p>"#;
289 FRAC_PI_2 = r#"$ π/2 = τ/4 = 90º $
290 ([A019669](https://oeis.org/A019669/constant))
291 `≈ 1.57079632…`"#;
292 FRAC_PI_3 = r#"$ π/3 = τ/6 = 60º $
293 ([A019670](https://oeis.org/A019670/constant))
294 `≈ 1.04719755…`"#;
295 FRAC_PI_4 = r#"$ π/4 = τ/8 = 45º $
296 ([A003881](https://oeis.org/A003881/constant))
297 `≈ 0.78539816…`"#;
298 FRAC_PI_6 = r#"$ π/6 = τ/12 = 30º $
299 ([A019673](https://oeis.org/A019673/constant))
300 `≈ 0.52359877…`"#;
301 FRAC_PI_8 = r#"$ π/8 = τ/16 = 22.5º $
302 ([A019675](https://oeis.org/A019675/constant))
303 `≈ 0.39269908…`"#;
304 SQRT_PI = r#"$ \sqrt{π} = \sqrt{\frac{1}{2} τ} $
305 ([A002161](https://oeis.org/A002161/constant))
306 `≈ 1.77245385…`"#;
307 FRAC_1_PI = r#"$ 1/π = 2/τ $
308 ([A049541](https://oeis.org/A049541/constant))
309 `≈ 0.31830988…`"#;
310 FRAC_1_SQRT_PI = r#"$ 1/\sqrt{π} = 1/\sqrt{τ/2} $
311 ([A087197](https://oeis.org/A087197/constant))
312 `≈ 0.56418958…`"#;
313 FRAC_1_SQRT_2PI = r#"$ 1/\sqrt{2π} = 1/\sqrt{τ} $
314 ([A231863](https://oeis.org/A231863/constant))
315 `≈ 0.39894228…`"#;
316 FRAC_2_PI = r#"$ 2/π $
317 ([A060294](https://oeis.org/A060294/constant))
318 `≈ 0.63661977…`
319 <p>*Buffon's constant*.</p>"#;
320 FRAC_2_SQRT_PI = r#"$ 2/\sqrt{π} $
321 ([A190732](https://oeis.org/A190732/constant))
322 `≈ 1.12837916…`"#;
323
324 TAU = r#"$ τ = 2π = 360º $
326 ([A019692](https://oeis.org/A019692/constant))
327 `≈ 6.28318530…`
328 <p>*The ratio of the circumference to the radius, a full-turn*.</p>"#;
329 FRAC_TAU_2 = r#"$ τ/2 = π = 180º $
330 ([A000796](https://oeis.org/A000796/constant))
331 `≈ 3.14159265…`"#;
332 FRAC_TAU_3 = r#"$ τ/3 = 2π/3 = 120º $
333 ([A019693](https://oeis.org/A019693/constant))
334 `≈ 2.09439510…`"#;
335 FRAC_TAU_4 = r#"$ τ/4 = π/2 = 90º $
336 ([A019693](https://oeis.org/A019693/constant))
337 `≈ 1.57079632…`"#;
338 FRAC_TAU_5 = r#"$ τ/5 = 2π/5 = 72º $
339 ([A019694](https://oeis.org/A019694/constant))
340 `≈ 1.25663706…`"#;
341 FRAC_TAU_6 = r#"$ τ/6 = π/3 = 60º $
342 ([A019670](https://oeis.org/A019670/constant))
343 `≈ 1.04719755…`"#;
344 FRAC_TAU_8 = r#"$ τ/8 = π/4 = 45º $
345 ([A003881](https://oeis.org/A003881/constant))
346 `≈ 0.78539816…`"#;
347 FRAC_TAU_9 = r#"$ τ/9 = 2π/9 = 40º $
348 ([A019696](https://oeis.org/A019696/constant))
349 `≈ 0.69813170…`"#;
350 FRAC_TAU_12 = r#"$ τ/12 = π/6 = 30º $
351 ([A019673](https://oeis.org/A019673/constant))
352 `≈ 0.52359877…`"#;
353 FRAC_TAU_16 = r#"$ τ/16 = π/8 = 22.5º $
354 ([A019675](https://oeis.org/A019675/constant))
355 `≈ 0.39269908…`"#;
356 FRAC_TAU_24 = r#"$ τ/24 = π/12 = 15º $
357 ([A019679](https://oeis.org/A019679/constant))
358 `≈ 0.26179938…`"#;
359 FRAC_TAU_72 = r#"$ τ/72 = π/36 = 5º $
360 `≈ 0.08726646…`"#;
361 FRAC_TAU_360 = r#"$ τ/360 = π/180 = 1º $ *arc degree*
362 ([A019685](https://oeis.org/A019685),
363 [wikipedia](https://en.wikipedia.org/wiki/Degree_(angle)))
364 `≈ 0.01745329…`"#;
365 FRAC_360_TAU = r#"$ 360/τ = 180/π $
366 ([A072097](https://oeis.org/A072097/constant))
367 `≈ 57.2957795…`"#;
368 SQRT_TAU = r#"$ \sqrt{τ} = \sqrt{2π} $
369 ([A019727](https://oeis.org/A019727/constant))
370 `≈ 2.50662827…`"#;
371 FRAC_1_TAU = r#"$ 1/τ = 1/2π $
372 ([A086201](https://oeis.org/A086201/constant))
373 `≈ 0.15915494…`"#;
374 FRAC_1_SQRT_TAU = r#"$ 1/\sqrt{τ} = 1/\sqrt{2π} $
375 ([A231863](https://oeis.org/A231863/constant))
376 `≈ 0.39894228…`"#;
377 FRAC_2_TAU = r#"$ 2/τ = 1/π $
378 ([A049541](https://oeis.org/A049541/constant))
379 `≈ 0.31830988…`"#;
380 FRAC_2_SQRT_TAU = r#"$ 2/\sqrt{τ} = \sqrt{2/π} $
381 ([A076668](https://oeis.org/A076668/constant))
382 `≈ 0.79788456…`"#;
383
384 ARC_DEGREE = r#"$ τ/360 = π/180 = 1º $ *arc degree*
386 ([A019685](https://oeis.org/A019685),
387 [wikipedia](https://en.wikipedia.org/wiki/Degree_(angle)))
388 `≈ 0.01745329…`"#;
389 ARC_MINUTE = r#"$ τ/(360*60) = 1' $ *arc minute*
390 ([wikipedia](https://en.wikipedia.org/wiki/Minute_and_second_of_arc))
391 `≈ 0.00029088…`"#;
392 ARC_SECOND = r#"$ τ/(360 * 60 * 60) = 1'' $ *arc second*
393 ([wikipedia](https://en.wikipedia.org/wiki/Minute_and_second_of_arc))
394 `≈ 0.00000484…`"#;
395
396 PHI = r#"$ φ = (1+\sqrt{5})/2 $
398 ([A001622](https://oeis.org/A001622/constant))
399 `≈ 1.61803398…`
400 <p>*The golden ratio*.</p>
401 <p>Continued fraction: $ [1;1,1,1,…] $</p>"#;
402 SQ_PHI = r#"$ φ^2 = φ+1 = (3+\sqrt{5})/2 $
403 ([A104457](https://oeis.org/A104457/constant))
404 `≈ 2.61803398…`"#;
405 FRAC_1_PHI = r#"$ 1/φ = φ-1 $
406 ([A094214](https://oeis.org/A094214/constant))
407 `≈ 0.61803398…`
408 <p>*The reciprocal of [φ][Self#PHI]*.</p>"#;
409 NEG_FRAC_1_PHI = r#"$ -1/φ = 1-φ $
410 `≈ -0.61803398…`
411 <p>*The negative reciprocal of [φ][Self#PHI] and its conjugate in $ x^2-x-1 $*.</p>"#;
412 SQRT_PHI = r#"$ \sqrt{φ} $
413 ([A139339](https://oeis.org/A139339/constant))
414 `≈ 1.27201964…`"#;
415 FRAC_1_SQRT_PHI = r#"$ 1/\sqrt{φ} = \sqrt{φ/φ^2} = \sqrt{φ^2-2} $
416 ([A197762](https://oeis.org/A197762/constant))
417 `≈ 0.78615137…`"#;
418 TRIBONACCI = r#"([A058265](https://oeis.org/A058265/constant))
419 `≈ 1.83928675…`
420 <p>*The tribonacci constant*.</p>"#;
421
422 SQRT_2 = r#"$ \sqrt{2} $
424 ([A002193](https://oeis.org/A002193/constant),
425 [wikipedia](https://en.wikipedia.org/wiki/Square_root_of_2))
426 `≈ 1.41421356…`"#;
427 FRAC_1_SQRT_2 = r#"$ 1/\sqrt{2} = \sqrt{1/2} $
428 ([A010503](https://oeis.org/A010503/constant),
429 [wikipedia](https://en.wikipedia.org/wiki/Square_root_of_2#Multiplicative_inverse))
430 `≈ 0.70710678…`"#;
431 SQRT_3 = r#"$ \sqrt{3} $
432 ([A002194](https://oeis.org/A002194/constant),
433 [wikipedia](https://en.wikipedia.org/wiki/Square_root_of_3))
434 `≈ 1.73205080…`"#;
435 FRAC_1_SQRT_3 = r#"$ 1/\sqrt{3} = \sqrt{1/3} $
436 ([A020760](https://oeis.org/A002194/constant),
437 `≈ 0.57735026…`"#;
438 SQRT_5 = r#"$ \sqrt{5} $
439 ([A002163](https://oeis.org/A002163/constant),
440 [wikipedia](https://en.wikipedia.org/wiki/Square_root_of_5))
441 `≈ 2.23606797…`"#;
442 SQRT_6 = r#"$ \sqrt{6} $
443 ([A010464](https://oeis.org/A010464/constant))
444 `≈ 2.44948974…`"#;
445 SQRT_7 = r#"$ \sqrt{7} $
446 ([A010465](https://oeis.org/A010465/constant))
447 `≈ 2.64575131…`"#;
448 SQRT_8 = r#"$ \sqrt{8} $
449 ([A010466](https://oeis.org/A010466/constant))
450 `≈ 2.82842712…`"#;
451 SQRT_10 = r#"$ \sqrt{10} $
452 ([A010467](https://oeis.org/A010467/constant))
453 `≈ 3.16227766…`"#;
454 SQRT_11 = r#"$ \sqrt{11} $
455 ([A010468](https://oeis.org/A010468/constant))
456 `≈ 3.31662479…`"#;
457 SQRT_12 = r#"$ \sqrt{12} $
458 ([A010469](https://oeis.org/A010469/constant))
459 `≈ 3.46410161…`"#;
460 CBRT_2 = r#"$ \sqrt[\small 3]{2} $
461 ([A002580](https://oeis.org/A002580/constant),
462 [wikipedia](https://en.wikipedia.org/wiki/Doubling_the_cube))
463 `≈ 1.25992104…`"#;
464 CBRT_3 = r#"$ \sqrt[\small 3]{3} $
465 ([A002581](https://oeis.org/A002581/constant))
466 `≈ 1.44224957…`"#;
467 FRAC_1_CBRT_3 = r#"$ 1/\sqrt[\small 3]{3} = (\normalsize\frac{1}{3})^{\small\frac{1}{3}} $
468 ([A072365](https://oeis.org/A072365/constant))
469 `≈ 0.69336127…`"#;
470
471 E = r#"$ e $
473 ([A001113](https://oeis.org/A001113/constant))
474 `≈ 2.71828182…`
475 <p>*The Euler number or Napier's constant*.</p>
476 <p>Continuous fraction: $ [2;1,2,1,1,4,1,1,6,1,…,1,2n,1,…] $</p>"#;
477 EGAMMA = r#"$ γ $
478 ([A001620](https://oeis.org/A001620/constant))
479 `≈ 0.57721566…`
480 <p>*Gamma, or the Euler-Mascheroni constant.*</p>"#;
481 LOG2_E = r#"$ \log_2{e} $
482 ([A007525](https://oeis.org/A007525/constant))
483 `≈ 1.44269504…`"#;
484 LOG2_10 = r#"log<sub>2</sub>(10)
485 ([A020862](https://oeis.org/A020862/constant))
486 `≈ 3.32192809…`"#;
487 LOG10_E = r#"log<sub>10</sub>(e)
488 ([A002285](https://oeis.org/A002285/constant))
489 `≈ 0.43429448…`"#;
490 LOG10_2 = r#"log<sub>10</sub>(2)
491 ([A007524](https://oeis.org/A007524/constant))
492 `≈ 0.30102999…`"#;
493 LN_2 = r#"ln(2)
494 ([A002162](https://oeis.org/A002162/constant))
495 `≈ 0.69314718…`"#;
496 LN_10 = r#"ln(10)
497 ([A002392](https://oeis.org/A002392/constant))
498 `≈ 2.30258509…`"#;
499}
500
501macro_rules! impl_ext_float_const {
505 ($( $(#[$attrs:meta])* $f:ty ),+) => { $( impl_ext_float_const![@$(#[$attrs])* $f]; )+ };
506 (@$(#[$attrs:meta])* $f:ty) => {
507 $(#[$attrs])*
509 impl ExtFloatConst for $f {
510 const ONE: $f = 1.0;
512 const ZERO: $f = 0.0;
513 const NEG_ONE: $f = -1.0;
514 const NEG_ZERO: $f = -0.0;
515
516 const NAN: $f = <$f>::NAN;
518 const INFINITY: $f = <$f>::INFINITY;
519 const NEG_INFINITY: $f = <$f>::NEG_INFINITY;
520 const EPSILON: $f = <$f>::EPSILON;
521 const LOW_MARGIN: $f = TempFloat::<$f>::LOW_MARGIN;
522 const MEDIUM_MARGIN: $f = TempFloat::<$f>::MEDIUM_MARGIN;
523 const HIGH_MARGIN: $f = TempFloat::<$f>::HIGH_MARGIN;
524 const RADIX: u32 = <$f>::RADIX;
525 const DIGITS: u32 = <$f>::DIGITS;
526 const MANTISSA_DIGITS: u32 = <$f>::MANTISSA_DIGITS;
527 const SIGNIFICAND_BITS: u32 = Float::<$f>::SIGNIFICAND_BITS;
528 const EXPONENT_BIAS: u32 = Float::<$f>::EXPONENT_BIAS;
529 const EXPONENT_BITS: u32 = Float::<$f>::EXPONENT_BITS;
530 const MIN: $f = <$f>::MIN;
531 const MIN_POSITIVE: $f = <$f>::MIN_POSITIVE;
532 const MAX: $f = <$f>::MAX;
533 const MIN_EXP: i32 = <$f>::MIN_EXP;
534 const MAX_EXP: i32 = <$f>::MAX_EXP;
535 const MIN_10_EXP: i32 = <$f>::MIN_10_EXP;
536 const MAX_10_EXP: i32 = <$f>::MAX_10_EXP;
537
538 const PI: $f =
540 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
541 const FRAC_PI_2: $f =
542 1.57079632679489661923132169163975144209858469968755291048747229615390820314310449;
543 const FRAC_PI_3: $f =
544 1.04719755119659774615421446109316762806572313312503527365831486410260546876206966;
545 const FRAC_PI_4: $f =
546 0.78539816339744830961566084581987572104929234984377645524373614807695410157155224;
547 const FRAC_PI_6: $f =
548 0.52359877559829887307710723054658381403286156656251763682915743205130273438103483;
549 const FRAC_PI_8: $f =
550 0.39269908169872415480783042290993786052464617492188822762186807403847705078577612;
551 const SQRT_PI: $f =
552 1.77245385090551602729816748334114518279754945612238712821380778985291128459103218;
553 const FRAC_1_PI: $f =
554 0.31830988618379067153776752674502872406891929148091289749533468811779359526845307;
555 const FRAC_1_SQRT_PI: $f =
556 0.56418958354775628694807945156077258584405062932899885684408572171064246844149341;
557 const FRAC_1_SQRT_2PI: $f = Self::FRAC_1_SQRT_TAU;
558 const FRAC_2_PI: $f =
559 0.63661977236758134307553505349005744813783858296182579499066937623558719053690614;
560 const FRAC_2_SQRT_PI: $f =
561 1.12837916709551257389615890312154517168810125865799771368817144342128493688298683;
562
563 const TAU: $f =
565 6.28318530717958647692528676655900576839433879875021164194988918461563281257241799;
566 const FRAC_TAU_2: $f = Self::PI;
567 const FRAC_TAU_3: $f =
568 2.09439510239319549230842892218633525613144626625007054731662972820521093752413933;
569 const FRAC_TAU_4: $f = Self::FRAC_PI_2;
570 const FRAC_TAU_5: $f =
571 1.25663706143591729538505735331180115367886775975004232838997783692312656251448359;
572 const FRAC_TAU_6: $f = Self::FRAC_PI_3;
573 const FRAC_TAU_8: $f = Self::FRAC_PI_4;
574 const FRAC_TAU_9: $f =
575 0.69813170079773183076947630739544508537714875541669018243887657606840364584137977;
576 const FRAC_TAU_12: $f = Self::FRAC_PI_6;
577 const FRAC_TAU_16: $f = Self::FRAC_PI_8;
578 const FRAC_TAU_24: $f =
579 0.26179938779914943653855361527329190701643078328125881841457871602565136719051741;
580 const FRAC_TAU_72: $f =
581 0.08726646259971647884618453842443063567214359442708627280485957200855045573017247;
582 const FRAC_TAU_360: $f =
583 0.01745329251994329576923690768488612713442871888541725456097191440171009114603449;
584 const FRAC_360_TAU: $f =
585 57.29577951308232087679815481410517033240547246656432154916024386120284714832155263;
586 const SQRT_TAU: $f =
587 2.50662827463100050241576528481104525300698674060993831662992357634229365460784197;
588 const FRAC_1_TAU: $f =
589 0.15915494309189533576888376337251436203445964574045644874766734405889679763422653;
590 const FRAC_1_SQRT_TAU: $f =
591 0.39894228040143267793994605993438186847585863116493465766592582967065792589930183;
592 const FRAC_2_TAU: $f = Self::FRAC_1_PI;
593 const FRAC_2_SQRT_TAU: $f =
594 0.79788456080286535587989211986876373695171726232986931533185165934131585179860367;
595
596 const ARC_DEGREE: $f = Self::FRAC_TAU_360;
598 const ARC_MINUTE: $f =
599 0.00029088820866572159615394846141476878557381198142362090934953190669516818576724;
600 const ARC_SECOND: $f =
601 0.00000484813681109535993589914102357947975956353302372701515582553177825280309612;
602
603 const PHI: $f =
605 1.61803398874989484820458683436563811772030917980576286213544862270526046281890244;
606 const SQ_PHI: $f =
607 2.61803398874989484820458683436563811772030917980576286213544862270526046281890244;
608 const FRAC_1_PHI: $f =
609 0.61803398874989484820458683436563811772030917980576286213544862270526046281890244;
610 const NEG_FRAC_1_PHI: $f =
611 -0.61803398874989484820458683436563811772030917980576286213544862270526046281890244;
612 const SQRT_PHI: $f =
613 1.27201964951406896425242246173749149171560804184009624861664038253929757553606801;
614 const FRAC_1_SQRT_PHI: $f =
615 0.78615137775742328606955858584295892952312205783772323766490197010118204762231091;
616 const TRIBONACCI: $f =
617 1.83928675521416113255185256465328660042417874609759224677875863940420322208196642;
618
619 const SQRT_2: $f =
621 1.41421356237309504880168872420969807856967187537694807317667973799073247846210703;
622 const FRAC_1_SQRT_2: $f =
623 0.70710678118654752440084436210484903928483593768847403658833986899536623923105351;
624 const SQRT_3: $f =
625 1.73205080756887729352744634150587236694280525381038062805580697945193301690880003;
626 const FRAC_1_SQRT_3: $f =
627 0.57735026918962576450914878050195745564760175127012687601860232648397767230293334;
628 const SQRT_5: $f =
629 2.23606797749978969640917366873127623544061835961152572427089724541052092563780489;
630 const SQRT_6: $f =
631 2.44948974278317809819728407470589139196594748065667012843269256725096037745731502;
632 const SQRT_7: $f =
633 2.64575131106459059050161575363926042571025918308245018036833445920106882323028362;
634 const SQRT_8: $f =
635 2.82842712474619009760337744841939615713934375075389614635335947598146495692421407;
636 const SQRT_10: $f =
637 3.16227766016837933199889354443271853371955513932521682685750485279259443863923822;
638 const SQRT_11: $f =
639 3.31662479035539984911493273667068668392708854558935359705868214611648464260904384;
640 const SQRT_12: $f =
641 3.46410161513775458705489268301174473388561050762076125611161395890386603381760007;
642 const CBRT_2: $f =
643 1.25992104989487316476721060727822835057025146470150798008197511215529967651395948;
644 const CBRT_3: $f =
645 1.44224957030740838232163831078010958839186925349935057754641619454168759682999733;
646 const FRAC_1_CBRT_3: $f =
647 0.69336127435063470484335227478596179544593511345775403656586369340003543713242292;
648
649 const E: $f =
651 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759;
652 const EGAMMA: $f =
653 0.57721566490153286060651209008240243104215933593992359880576723488486772677766467;
654 const LOG2_E: $f =
655 1.44269504088896340735992468100189213742664595415298593413544940693110921918118507;
656 const LOG2_10: $f =
657 3.32192809488736234787031942948939017586483139302458061205475639581593477660862521;
658 const LOG10_E: $f =
659 0.43429448190325182765112891891660508229439700580366656611445378316586464920887077;
660 const LOG10_2: $f =
661 0.30102999566398119521373889472449302676818988146210854131042746112710818927442450;
662 const LN_2: $f =
663 0.69314718055994530941723212145817656807550013436025525412068000949339362196969471;
664 const LN_10: $f =
665 2.30258509299404568401799145468436420760110148862877297603332790096757260967735248;
666 }
667 };
668}
669impl_ext_float_const![f32, f64];
670#[cfg(feature = "nightly_float")]
671impl_ext_float_const![
672 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "nightly_float")))]
673 f16,
674 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "nightly_float")))]
675 f128
676];
677
678struct TempFloat<T> {
680 _marker: ::core::marker::PhantomData<T>,
681}
682macro_rules! impl_temp_float {
683 () => {
684 #[cfg(feature = "nightly_float")]
685 impl_temp_float![f16: 1e-4, 1e-3, 1e-2]; impl_temp_float![f32: 1e-7, 1e-6, 1e-5]; impl_temp_float![f64: 1e-12, 1e-9, 1e-6]; #[cfg(feature = "nightly_float")]
689 impl_temp_float![f128: 1e-30, 1e-27, 1e-24]; };
691 ($f:ty: $lm:literal, $mm:literal, $hm:literal) => {
692 impl TempFloat<$f> {
693 pub const LOW_MARGIN: $f = $lm;
695 pub const MEDIUM_MARGIN: $f = $mm;
696 pub const HIGH_MARGIN: $f = $hm;
697 }
698 };
699}
700impl_temp_float![];