Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Overloading print()

by pilcrow (Sexton)
on Sep 05, 2007 at 17:28 UTC ( [id://637217]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Overloading print()
in thread Overloading print()

"Wouldn't it be nice if print was overloaded to use mpfr_out_str" ... But then, that would mean that every time someone did $x = "$blessed_obj"; the value encapsulated in $blessed_obj is going to be printed to stdout

mpfr_get_str() probably does what you want here. If so, I'd wager that Math::MPFR already does what you want, since it exposes Rmpfr_get_str() and, using it, already overloads its objects' stringification.

-pilcrow

Replies are listed 'Best First'.
Re^4: Overloading print()
by syphilis (Archbishop) on Sep 06, 2007 at 05:52 UTC
    mpfr_get_str() probably does what you want here

    Unfortunately it doesn't. All it does is return a string of digits (with a leading minus sign if it's a negative number) for the mantissa, and sets a variable to the value of the exponent. It's then up to Rmpfr_get_str to put the number into scientific notation, based on the information provided by mpfr_get_str.

    If, as one would instinctively expect, mpfr_get_str returned a string formatted in the same way as the mpfr_out_str output, then you would be absolutely correct ... and this whole thread would never bave been born :-)

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://637217]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-19 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found