简体   繁体   English

MPFR 最大值 integer 值

[英]MPFR max integer value

Do mpfr_t types have a limit on the largest integer value they can store or is the integer component effectively unlimited (only limited by memory limits on the target machine) like mpz_t types are? mpfr_t类型是否对它们可以存储的最大 integer 值有限制,或者 integer 组件是否有效不受限制(仅受mpz_t限制),例如目标机器类型的限制?

If so is there an easy way to detect overflow whilst parsing a value?如果是这样,是否有一种简单的方法可以在解析值时检测溢出?

You can represent larger integers than what mpz_t can thanks to the exponent, but you may want to extend the exponent range with mpfr_set_emax , so that the maximum representable integer will be almost 2^(2^62−1) on a 64-bit platform.由于指数,您可以表示比mpz_t更大的整数,但您可能希望使用mpfr_set_emax扩展指数范围,以便最大可表示的 integer 在 64 位平台上几乎为 2^(2^62−1) . That said, you will not be able to represent all integers exactly since some integers (in particular the odd ones) would require too much precision.也就是说,您将无法准确表示所有整数,因为某些整数(尤其是奇数)需要太多的精度。 Concerning the limit on the precision, the theoretical limit in MPFR is MPFR_PREC_MAX , which is huge on 64-bit platforms.关于精度的限制,MPFR 的理论限制是MPFR_PREC_MAX ,这在 64 位平台上是巨大的。 But in practice, you'll first hit either the limit from the amount of memory or the limit of 2^37 bits on the mpz_t size.但在实践中,您将首先达到 memory 数量的限制或mpz_t大小的 2^37 位的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM