almut++ ... a truly edifying piece of code which does exactly what I was after.
However, looking at the hoops it jumps through, I start to wonder about its portability and reliability. (Could it potentially create more problems for me than it solves ?)
And I couldn't work out how to restore the original stdout on perl 5.6 (where ">&" is not understood) - though that's not really a major consideration.
So ... I'm not yet sure whether I'll implement that approach, but thanks for going to the trouble of presenting such a well written and useful demo.
Math::MPFR already overloads
"". The version on CPAN doesn't render inf, nan, and -0 as it should, though that's taken care of in the next release. Apart from that, the only difference (I'm aware of) between the overloaded
"" and
mpfr_out_str is that
mpfr_out_str doesn't strip trailing zeros, whereas perl *does* strip them. (That is, whereas
mpfr_out_str might render a number as
1.23450000e1, the overloaded
"" will return
1.2345e1.) I don't see any need to be concerned about that discrepancy. The appeal of having the overloaded
"" wrap
mpfr_out_str is simply that I can then be certain that the outputs will match ... without even having to consider the many-and-varied "what if" scenarios.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.