Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^7: How does Math::GMP overload the assignment operator ? (more guessing)

by Haarg (Curate)
on Nov 10, 2020 at 19:54 UTC ( #11123558=note: print w/replies, xml ) Need Help??


in reply to Re^6: How does Math::GMP overload the assignment operator ? (more guessing)
in thread How does Math::GMP overload the assignment operator ?

sprintf and pack can trigger the 0+ overload, even if all other ops are overloaded.
  • Comment on Re^7: How does Math::GMP overload the assignment operator ? (more guessing)

Replies are listed 'Best First'.
Re^8: How does Math::GMP overload the assignment operator ? (more guessing)
by syphilis (Bishop) on Nov 11, 2020 at 00:55 UTC
    sprintf and pack can trigger the 0+ overload

    Now that you mention it, I do recall experiencing that overloading with sprintf(), but I failed to recognize it for what it was.
    "How the hell does that work ?", I thought ... and then quickly replied "Gee, that's handy !" ... whereupon that particular conversation with myself was abruptly ended.
    For anyone seeking an example:
    C:\>perl -MMath::GMP -le "printf '%x', Math::GMP->new(10);" a C:\>perl -MMath::GMP -le "print unpack 'H*', pack 'I>', Math::GMP->new +(254);" 000000fe
    Cheers,
    Rob

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (None)
    As of 2021-10-21 04:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (82 votes). Check out past polls.

      Notices?