1use std::fmt;
5use std::error::Error;
6use std::collections::HashMap;
7
8use crate::prim::{*, typ::*, mpz::*, randstate::*, gmp::*}; use crate::util;
10
11#[repr(C)]
14pub struct __mpf_struct {
15 pub _mp_prec: int_t,
17 pub _mp_size: int_t,
19 pub _mp_exp: mp_exp_t,
21 pub _mp_d: *mut mp_limb_t
23}
24
25impl SNew for __mpf_struct {
27 fn new() -> Self {
29 __mpf_struct {
30 _mp_prec: 0,
31 _mp_size: 0,
32 _mp_exp: 0,
33 _mp_d: 0 as *mut mp_limb_t
34 }
35 }
36}
37
38impl Drop for __mpf_struct {
40 fn drop(&mut self) {
41 self.clear()
42 }
43}
44
45impl __mpf_struct {
47 pub fn clear(&mut self) -> () {
49 mpf_clear(self)
50 }
51
52 pub fn init() -> Self {
54 let mut t = mpf_s::new();
55 mpf_init(&mut t);
56 t
57 }
58
59 pub fn init2(n: mp_bitcnt_t) -> Self {
61 let mut t = mpf_s::new();
62 mpf_init2(&mut t, n);
63 t
64 }
65
66 pub fn init_set(f: mpf_r) -> Self {
68 let mut t = mpf_s::new();
69 mpf_init_set(&mut t, f);
70 t
71 }
72
73 pub fn init_set_ui(u: ui_t) -> Self {
75 let mut t = mpf_s::new();
76 mpf_init_set_ui(&mut t, u);
77 t
78 }
79
80 pub fn init_set_si(s: si_t) -> Self {
82 let mut t = mpf_s::new();
83 mpf_init_set_si(&mut t, s);
84 t
85 }
86
87 pub fn init_set_d(d: double_t) -> Self {
89 let mut t = mpf_s::new();
90 mpf_init_set_d(&mut t, d);
91 t
92 }
93
94 pub fn init_set_str(s: &str, b: int_t) -> Self {
96 let mut t = mpf_s::new();
97 mpf_init_set_str(&mut t, s, b);
98 t
99 }
100
101 pub fn fmtstr(&self, b: int_t, d: mp_size_t) -> String {
103 mpf_get_fmtstr(self, b, d).expect("mpf fmtstr")
104 }
105
106 pub fn set(&mut self, f: mpf_r) -> &mut Self {
108 mpf_set(self, f);
109 self
110 }
111
112 pub fn set_ui(&mut self, u: ui_t) -> &mut Self {
114 mpf_set_ui(self, u);
115 self
116 }
117
118 pub fn set_si(&mut self, s: si_t) -> &mut Self {
120 mpf_set_si(self, s);
121 self
122 }
123
124 pub fn set_d(&mut self, d: double_t) -> &mut Self {
126 mpf_set_d(self, d);
127 self
128 }
129
130 pub fn set_z(&mut self, a: mpz_r) -> &mut Self {
132 mpf_set_z(self, a);
133 self
134 }
135
136 pub fn set_str(&mut self, s: &str, b: int_t) -> &mut Self {
138 mpf_set_str(self, s, b);
139 self
140 }
141
142 pub fn get_d(&self) -> double_t {
144 mpf_get_d(self)
145 }
146
147 pub fn get_ui(&self) -> ui_t {
149 mpf_get_ui(self)
150 }
151
152 pub fn get_si(&self) -> si_t {
154 mpf_get_si(self)
155 }
156
157 pub fn get_d_2exp(&self) -> (double_t, si_t) {
159 let mut e: si_t = 0;
160 let d = mpf_get_d_2exp(&mut e, self);
161 (d, e)
162 }
163
164 pub fn cmp(&self, g: mpf_r) -> int_t {
166 mpf_cmp(self, g)
167 }
168
169 pub fn cmp_d(&self, d: double_t) -> int_t {
171 mpf_cmp_d(self, d)
172 }
173
174 pub fn cmp_ui(&self, u: ui_t) -> int_t {
176 mpf_cmp_ui(self, u)
177 }
178
179 pub fn cmp_si(&self, s: si_t) -> int_t {
181 mpf_cmp_si(self, s)
182 }
183
184 pub fn cmp_z(&self, a: mpz_r) -> int_t {
186 mpf_cmp_z(self, a)
187 }
188
189 pub fn eq(&self, g: mpf_r, n: mp_bitcnt_t) -> int_t {
191 mpf_eq(self, g, n)
192 }
193
194 pub fn sgn(&self) -> int_t {
196 mpf_sgn(self)
197 }
198
199 pub fn reldiff(&self, e: mpf_r) -> Self {
201 let mut t = mpf_s::init(); mpf_reldiff(&mut t, self, e);
203 t
204 }
205
206 pub fn sqrt(&self) -> Self {
208 let mut t = mpf_s::init(); mpf_sqrt(&mut t, self);
210 t
211 }
212
213 pub fn sqrt_ui(u: ui_t) -> Self {
215 let mut t = mpf_s::init(); mpf_sqrt_ui(&mut t, u);
217 t
218 }
219
220 pub fn abs(&self) -> Self {
222 let mut t = mpf_s::init(); mpf_abs(&mut t, self);
224 t
225 }
226
227 pub fn neg(&self) -> Self {
229 let mut t = mpf_s::init(); mpf_neg(&mut t, self);
231 t
232 }
233
234 pub fn sub(&mut self, e: mpf_r) -> &mut Self {
236 mpf_sub(self, &mpf_s::init_set(self), e);
237 self
238 }
239
240 pub fn sub_ui(&mut self, u: ui_t) -> &mut Self {
242 mpf_sub_ui(self, &mpf_s::init_set(self), u);
243 self
244 }
245
246 pub fn ui_sub(&mut self, u: ui_t) -> &mut Self {
248 mpf_ui_sub(self, u, &mpf_s::init_set(self));
249 self
250 }
251
252 pub fn add(&mut self, e: mpf_r) -> &mut Self {
254 mpf_add(self, &mpf_s::init_set(self), e);
255 self
256 }
257
258 pub fn add_ui(&mut self, u: ui_t) -> &mut Self {
260 mpf_add_ui(self, &mpf_s::init_set(self), u);
261 self
262 }
263
264 pub fn mul(&mut self, e: mpf_r) -> &mut Self {
266 mpf_mul(self, &mpf_s::init_set(self), e);
267 self
268 }
269
270 pub fn mul_ui(&mut self, u: ui_t) -> &mut Self {
272 mpf_mul_ui(self, &mpf_s::init_set(self), u);
273 self
274 }
275
276 pub fn mul_2exp(&mut self, n: mp_bitcnt_t) -> &mut Self {
278 mpf_mul_2exp(self, &mpf_s::init_set(self), n);
279 self
280 }
281
282 pub fn div(&mut self, e: mpf_r) -> &mut Self {
284 mpf_div(self, &mpf_s::init_set(self), e);
285 self
286 }
287
288 pub fn div_ui(&mut self, u: ui_t) -> &mut Self {
290 mpf_div_ui(self, &mpf_s::init_set(self), u);
291 self
292 }
293
294 pub fn ui_div(&mut self, u: ui_t) -> &mut Self {
296 mpf_ui_div(self, u, &mpf_s::init_set(self));
297 self
298 }
299
300 pub fn div_2exp(&mut self, n: mp_bitcnt_t) -> &mut Self {
302 mpf_div_2exp(self, &mpf_s::init_set(self), n);
303 self
304 }
305
306 pub fn pow_ui(f: mpf_r, n: ui_t) -> Self {
308 let mut t = mpf_s::init(); mpf_pow_ui(&mut t, f, n);
310 t
311 }
312
313 pub fn ceil(&self) -> Self {
315 let mut t = mpf_s::init();
316 mpf_ceil(&mut t, self);
317 t
318 }
319
320 pub fn floor(&self) -> Self {
322 let mut t = mpf_s::init();
323 mpf_floor(&mut t, self);
324 t
325 }
326
327 pub fn trunc(&self) -> Self {
329 let mut t = mpf_s::init();
330 mpf_trunc(&mut t, self);
331 t
332 }
333
334 pub fn integer_p(&self) -> bool {
336 mpf_integer_p(self)
337 }
338
339 pub fn fits_ulong_p(&self) -> bool {
341 mpf_fits_ulong_p(self)
342 }
343
344 pub fn fits_slong_p(&self) -> bool {
346 mpf_fits_slong_p(self)
347 }
348
349 pub fn fits_uint_p(&self) -> bool {
351 mpf_fits_uint_p(self)
352 }
353
354 pub fn fits_sint_p(&self) -> bool {
356 mpf_fits_sint_p(self)
357 }
358
359 pub fn fits_ushort_p(&self) -> bool {
361 mpf_fits_ushort_p(self)
362 }
363
364 pub fn fits_sshort_p(&self) -> bool {
366 mpf_fits_sshort_p(self)
367 }
368
369 pub fn urandomb(state: randstate_t, nbits: mp_bitcnt_t) -> Self {
371 let mut t = mpf_s::init();
372 mpf_urandomb(&mut t, state, nbits);
373 t
374 }
375
376 pub fn random2(max_size: mp_size_t, e: mp_exp_t) -> Self {
378 let mut t = mpf_s::init();
379 mpf_random2(&mut t, max_size, e);
380 t
381 }
382
383 pub fn get_prec(&self) -> mp_bitcnt_t {
385 mpf_get_prec(self)
386 }
387
388 pub fn set_prec(&mut self, n: mp_bitcnt_t) -> () {
390 mpf_set_prec(self, n)
391 }
392
393 pub fn set_prec_raw(&mut self, n: mp_bitcnt_t) -> () {
395 mpf_set_prec_raw(self, n)
396 }
397
398 pub fn calc_bits_from_digits(d: mp_size_t) -> mp_bitcnt_t {
400 (10f64.log2() * (d + 1) as f64) as mp_bitcnt_t
401 }
402
403 pub fn calc_digits_from_bits(n: mp_bitcnt_t) -> mp_size_t {
405 (n as f64 / 10f64.log2()) as mp_size_t
406 }
407
408 pub fn calc_pi_gauss_legendre(digits: mp_size_t) -> Self {
410 let recursion = digits.ilog2(); let a = &mut mpf_s::init_set_ui(1);
412 let b = &mut mpf_s::sqrt_ui(2);
413 let t = &mut mpf_s::init_set_ui(4);
414 let p = &mut mpf_s::init_set_ui(1);
415 let (a, b, t, _p) = (0..recursion).fold((a, b.ui_div(1), t.ui_div(1), p),
416 |(a, b, t, p), _k| {
417 let na = &mut mpf_s::init_set(a); na.add(b).div_ui(2);
419 let nb = &b.mul(a).sqrt(); t.sub(mpf_s::pow_ui(a.sub(na), 2).mul(p)); (a.set(na), b.set(nb), t, p.mul_ui(2)) });
423 let mut pi = mpf_s::pow_ui(a.add(b), 2);
424 pi.div_ui(4).div(t);
425 pi
426 }
427
428 pub fn calc_pi_euler(digits: mp_size_t) -> Self {
430 let mut pi = mpf_s::init_set_ui(1);
431 let g = &mut mpf_s::init_set_ui(0);
432 let d = 10usize.pow(digits as u32);
433 let mut ept = util::EraPrimeTableUI::new(d);
434 let _p = (0..ept.nprimes()).fold(&mut pi, |pi: mpf_t, k| {
435 let np = ept.nth_prime(k, 0); let pp = &mpz_s::pow_ui(np, 2);
437 pi.mul(&mut g.set_z(pp).ui_div(1).ui_sub(1).ui_div(1));
438 pi
439 });
440 pi.mul_ui(6).sqrt()
441 }
442
443 pub fn calc_napier(x: mpf_r, digits: mp_size_t) -> Self {
445 let significant_digits_of_calc_napier = |n: f64| -> f64 {
447 let p = (2.0 * std::f64::consts::PI * n).sqrt().log10(); let q = n * (n / std::f64::consts::E).log10(); p + q - 1.0
450 };
451
452 let mut e = mpf_s::init_set_ui(0);
453let g = &mut mpf_s::init_set_ui(0);
455 let m = &mut HashMap::<ui_t, mpz_s>::new();
456 let _s = (0..=digits as ui_t).try_fold(&mut e, |e: mpf_t, i| {
457 let d = if i == 0 { 0 } else { significant_digits_of_calc_napier(i as f64) as mp_size_t };
459let n = &mpz_s::fact_cached(i, m);
461 let f = &mut mpf_s::pow_ui(x, i);
462 e.add(f.div(g.set_z(n)));
463if d >= digits { None } else { Some(e) }
472 }); e
474 }
475}
476
477impl fmt::Debug for __mpf_struct {
479 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
481 let mut s = String::from("");
482unsafe {
483 let mut sz = self._mp_size;
484 sz = if sz < 0 { -sz } else { sz };
485 std::slice::from_raw_parts(self._mp_d, sz as usize).iter()
486 .for_each(|d| s += format!(" {:016x}", d).as_str())
487}
488 write!(f, "{}, {}, {}{}", self._mp_prec, self._mp_size, self._mp_exp, s)
489 }
490}
491
492impl fmt::Display for __mpf_struct {
494 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
496 write!(f, "{}", self.fmtstr(10, 20))
497 }
498}
499
500#[allow(non_camel_case_types)]
502pub type mpf_s = __mpf_struct; #[allow(non_camel_case_types)]
505pub type mpf_t<'a> = &'a mut mpf_s; #[allow(non_camel_case_types)]
508pub type mpf_r<'a> = &'a mpf_s; pub fn mpf_clears(vf: &mut Vec<mpf_t>) -> () {
512 vf.iter_mut().for_each(|f| {
513 unsafe { __gmpf_clear(*f) } })
515}
516
517#[inline]
519pub fn mpf_clear(f: mpf_t) -> () {
520 unsafe { __gmpf_clear(f) }
521}
522
523pub fn mpf_inits(vf: &mut Vec<mpf_t>) -> () {
525 vf.iter_mut().for_each(|f| {
526 unsafe { __gmpf_init(*f) } })
528}
529
530#[inline]
532pub fn mpf_init(f: mpf_t) -> () {
533 unsafe { __gmpf_init(f) }
534}
535
536#[inline]
538pub fn mpf_init2(f: mpf_t, n: mp_bitcnt_t) -> () {
539 unsafe { __gmpf_init2(f, n) }
540}
541
542#[inline]
544pub fn mpf_init_set(f: mpf_t, g: mpf_r) -> () {
545 unsafe { __gmpf_init_set(f, g) }
546}
547
548#[inline]
550pub fn mpf_init_set_ui(f: mpf_t, u: ui_t) -> () {
551 unsafe { __gmpf_init_set_ui(f, u) }
552}
553
554#[inline]
556pub fn mpf_init_set_si(f: mpf_t, s: si_t) -> () {
557 unsafe { __gmpf_init_set_si(f, s) }
558}
559
560#[inline]
562pub fn mpf_init_set_d(f: mpf_t, d: double_t) -> () {
563 unsafe { __gmpf_init_set_d(f, d) }
564}
565
566#[inline]
568pub fn mpf_init_set_str(f: mpf_t, s: &str, b: int_t) -> () {
569 mpf_init_set_str_u8z(f, to_u8z!(s), b)
570}
571
572#[inline]
574pub fn mpf_init_set_str_u8z(f: mpf_t, s: &[u8], b: int_t) -> () {
575 unsafe { __gmpf_init_set_str(f, s as *const [u8] as *const u8, b) }
576}
577
578#[inline]
580pub fn mpf_set(f: mpf_t, g: mpf_r) -> () {
581 unsafe { __gmpf_set(f, g) }
582}
583
584#[inline]
586pub fn mpf_set_ui(f: mpf_t, u: ui_t) -> () {
587 unsafe { __gmpf_set_ui(f, u) }
588}
589
590#[inline]
592pub fn mpf_set_si(f: mpf_t, s: si_t) -> () {
593 unsafe { __gmpf_set_si(f, s) }
594}
595
596#[inline]
598pub fn mpf_set_d(f: mpf_t, d: double_t) -> () {
599 unsafe { __gmpf_set_d(f, d) }
600}
601
602#[inline]
604pub fn mpf_set_z(f: mpf_t, a: mpz_r) -> () {
605 unsafe { __gmpf_set_z(f, a) }
606}
607
608#[inline]
610pub fn mpf_set_str(f: mpf_t, s: &str, b: int_t) -> () {
611 mpf_set_str_u8z(f, to_u8z!(s), b)
612}
613
614#[inline]
616pub fn mpf_set_str_u8z(f: mpf_t, s: &[u8], b: int_t) -> () {
617 unsafe { __gmpf_set_str(f, s as *const [u8] as *const u8, b) }
618}
619
620pub fn mpf_get_u8z<'a>(s: Option<&mut [u8]>,
622 e: &'a mut mp_exp_t, b: int_t, d: mp_size_t, f: &'a mpf_s) ->
623 Option<Vec<u8>> {
624 let ff = s == None;
625unsafe {
626 let p = __gmpf_get_str(
627 match s { None => 0 as *mut u8, Some(s) => s as *mut [u8] as *mut u8 },
628 e, b, d, f);
629 u8zvec(p, ff) }
640}
641
642pub fn mpf_get_str<'a>(s: Option<&mut String>,
645 e: &'a mut mp_exp_t, b: int_t, d: mp_size_t, f: &'a mpf_s) ->
646 Result<String, Box<dyn Error>> {
647 let r = mpf_get_u8z(
648 match s { None => None, Some(s) => Some(unsafe { s.as_bytes_mut() }) },
649 e, b, d, f);
650 match r {
651 None => Err("err mpf get str".into()),
652 Some(r) => Ok(String::from_utf8(r)?)
653 }
654}
655
656pub fn mpf_get_fmtstr<'a>(f: &'a mpf_s, b: int_t, d: mp_size_t) ->
658 Result<String, Box<dyn Error>> {
659 let e = &mut (0 as mp_exp_t);
660 let r = mpf_get_u8z(None, e, b, d, f);
661 match r {
662 None => Err("err mpf get fmtstr".into()),
663 Some(r) => {
664 let (l, z) = (r.len(), String::from("0"));
665 let (sign, o) = if f._mp_size < 0 { ("-", 1) } else { ("", 0) };
666 let (es, en) = if *e < 0 { ("-", -1) } else { ("+", 1) };
667 let s = if o == l { z } else { String::from_utf8(r[o..l].to_vec())? };
668 Ok(format!("{}0.{}e{}{}", sign, s, es, *e * en))
669 }
670 }
671}
672
673#[inline]
675pub fn mpf_get_d(f: mpf_r) -> double_t {
676 unsafe { __gmpf_get_d(f) }
677}
678
679#[inline]
681pub fn mpf_get_ui(f: mpf_r) -> ui_t {
682 unsafe { __gmpf_get_ui(f) }
683}
684
685#[inline]
687pub fn mpf_get_si(f: mpf_r) -> si_t {
688 unsafe { __gmpf_get_si(f) }
689}
690
691#[inline]
693pub fn mpf_get_d_2exp(e: &mut si_t, f: mpf_r) -> double_t {
694 unsafe { __gmpf_get_d_2exp(e, f) }
695}
696
697#[inline]
699pub fn mpf_cmp(f: mpf_r, g: mpf_r) -> int_t {
700 unsafe { __gmpf_cmp(f, g) }
701}
702
703#[inline]
705pub fn mpf_cmp_d(f: mpf_r, d: double_t) -> int_t {
706 unsafe { __gmpf_cmp_d(f, d) }
707}
708
709#[inline]
711pub fn mpf_cmp_ui(f: mpf_r, u: ui_t) -> int_t {
712 unsafe { __gmpf_cmp_ui(f, u) }
713}
714
715#[inline]
717pub fn mpf_cmp_si(f: mpf_r, s: si_t) -> int_t {
718 unsafe { __gmpf_cmp_si(f, s) }
719}
720
721#[inline]
723pub fn mpf_cmp_z(f: mpf_r, a: mpz_r) -> int_t {
724 unsafe { __gmpf_cmp_z(f, a) }
725}
726
727#[inline]
729pub fn mpf_eq(f: mpf_r, g: mpf_r, n: mp_bitcnt_t) -> int_t {
730 unsafe { __gmpf_eq(f, g, n) }
731}
732
733#[inline]
735pub fn mpf_sgn(f: mpf_r) -> int_t {
736let t = f._mp_size;
738 if t < 0 { -1 } else { if t > 0 { 1 } else { 0 } }
739}
740
741#[inline]
743pub fn mpf_reldiff(g: mpf_t, f: mpf_r, e: mpf_r) -> () {
744 unsafe { __gmpf_reldiff(g, f, e) }
745}
746
747#[inline]
749pub fn mpf_sqrt(g: mpf_t, f: mpf_r) -> () {
750 unsafe { __gmpf_sqrt(g, f) }
751}
752
753#[inline]
755pub fn mpf_sqrt_ui(g: mpf_t, u: ui_t) -> () {
756 unsafe { __gmpf_sqrt_ui(g, u) }
757}
758
759#[inline]
761pub fn mpf_abs(g: mpf_t, f: mpf_r) -> () {
762 unsafe { __gmpf_abs(g, f) }
763}
764
765#[inline]
767pub fn mpf_neg(g: mpf_t, f: mpf_r) -> () {
768 unsafe { __gmpf_neg(g, f) }
769}
770
771#[inline]
773pub fn mpf_sub(g: mpf_t, f: mpf_r, e: mpf_r) -> () {
774 unsafe { __gmpf_sub(g, f, e) }
775}
776
777#[inline]
779pub fn mpf_sub_ui(g: mpf_t, f: mpf_r, u: ui_t) -> () {
780 unsafe { __gmpf_sub_ui(g, f, u) }
781}
782
783#[inline]
785pub fn mpf_ui_sub(g: mpf_t, u: ui_t, f: mpf_r) -> () {
786 unsafe { __gmpf_ui_sub(g, u, f) }
787}
788
789#[inline]
791pub fn mpf_add(g: mpf_t, f: mpf_r, e: mpf_r) -> () {
792 unsafe { __gmpf_add(g, f, e) }
793}
794
795#[inline]
797pub fn mpf_add_ui(g: mpf_t, f: mpf_r, u: ui_t) -> () {
798 unsafe { __gmpf_add_ui(g, f, u) }
799}
800
801#[inline]
803pub fn mpf_mul(g: mpf_t, f: mpf_r, e: mpf_r) -> () {
804 unsafe { __gmpf_mul(g, f, e) }
805}
806
807#[inline]
809pub fn mpf_mul_ui(g: mpf_t, f: mpf_r, u: ui_t) -> () {
810 unsafe { __gmpf_mul_ui(g, f, u) }
811}
812
813#[inline]
815pub fn mpf_mul_2exp(g: mpf_t, f: mpf_r, n: mp_bitcnt_t) -> () {
816 unsafe { __gmpf_mul_2exp(g, f, n) }
817}
818
819#[inline]
821pub fn mpf_div(g: mpf_t, f: mpf_r, e: mpf_r) -> () {
822 unsafe { __gmpf_div(g, f, e) }
823}
824
825#[inline]
827pub fn mpf_div_ui(g: mpf_t, f: mpf_r, u: ui_t) -> () {
828 unsafe { __gmpf_div_ui(g, f, u) }
829}
830
831#[inline]
833pub fn mpf_ui_div(g: mpf_t, u: ui_t, f: mpf_r) -> () {
834 unsafe { __gmpf_ui_div(g, u, f) }
835}
836
837#[inline]
839pub fn mpf_div_2exp(g: mpf_t, f: mpf_r, n: mp_bitcnt_t) -> () {
840 unsafe { __gmpf_div_2exp(g, f, n) }
841}
842
843#[inline]
845pub fn mpf_pow_ui(g: mpf_t, f: mpf_r, n: ui_t) -> () {
846 unsafe { __gmpf_pow_ui(g, f, n) }
847}
848
849#[inline]
851pub fn mpf_ceil(g: mpf_t, f: mpf_r) -> () {
852 unsafe { __gmpf_ceil(g, f) }
853}
854
855#[inline]
857pub fn mpf_floor(g: mpf_t, f: mpf_r) -> () {
858 unsafe { __gmpf_floor(g, f) }
859}
860
861#[inline]
863pub fn mpf_trunc(g: mpf_t, f: mpf_r) -> () {
864 unsafe { __gmpf_trunc(g, f) }
865}
866
867#[inline]
869pub fn mpf_integer_p(f: mpf_r) -> bool {
870 unsafe { __gmpf_integer_p(f) != 0 }
871}
872
873#[inline]
875pub fn mpf_fits_ulong_p(f: mpf_r) -> bool {
876 unsafe { __gmpf_fits_ulong_p(f) != 0 }
877}
878
879#[inline]
881pub fn mpf_fits_slong_p(f: mpf_r) -> bool {
882 unsafe { __gmpf_fits_slong_p(f) != 0 }
883}
884
885#[inline]
887pub fn mpf_fits_uint_p(f: mpf_r) -> bool {
888 unsafe { __gmpf_fits_uint_p(f) != 0 }
889}
890
891#[inline]
893pub fn mpf_fits_sint_p(f: mpf_r) -> bool {
894 unsafe { __gmpf_fits_sint_p(f) != 0 }
895}
896
897#[inline]
899pub fn mpf_fits_ushort_p(f: mpf_r) -> bool {
900 unsafe { __gmpf_fits_ushort_p(f) != 0 }
901}
902
903#[inline]
905pub fn mpf_fits_sshort_p(f: mpf_r) -> bool {
906 unsafe { __gmpf_fits_sshort_p(f) != 0 }
907}
908
909#[inline]
911pub fn mpf_urandomb(g: mpf_t, state: randstate_t, nbits: mp_bitcnt_t) -> () {
912 unsafe { __gmpf_urandomb(g, state, nbits) }
913}
914
915#[inline]
917pub fn mpf_random2(g: mpf_t, max_size: mp_size_t, e: mp_exp_t) -> () {
918 unsafe { __gmpf_random2(g, max_size, e) }
919}
920
921#[inline]
923pub fn mpf_get_default_prec() -> mp_bitcnt_t {
924 unsafe { __gmpf_get_default_prec() }
925}
926
927#[inline]
929pub fn mpf_get_prec(f: mpf_r) -> mp_bitcnt_t {
930 unsafe { __gmpf_get_prec(f) }
931}
932
933#[inline]
935pub fn mpf_set_default_prec(n: mp_bitcnt_t) -> () {
936 unsafe { __gmpf_set_default_prec(n) }
937}
938
939#[inline]
941pub fn mpf_set_prec(f: mpf_t, n: mp_bitcnt_t) -> () {
942 unsafe { __gmpf_set_prec(f, n) }
943}
944
945#[inline]
947pub fn mpf_set_prec_raw(f: mpf_t, n: mp_bitcnt_t) -> () {
948 unsafe { __gmpf_set_prec_raw(f, n) }
949}