简体   繁体   中英

How do I convert a num::Rational to a decimal number?

I'm trying to use the external library num with the goal to convert fractions to arbitrarily long decimal points, however, by reading the docs, I cannot find some clarifying example to convert a fraction to a decimal number. Anyone know how?

I think that printing out arbitrary precision decimals is simply a hard problem. I don't see that the GNU Multiple Precision (GMP) Arithmetic Library supports this functionality. While Rust isn't built on top of GMP, if GMP doesn't have it I wouldn't expect Rust to have it.

The best you may be able to do is divide the numerator by the denominator yourself...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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