Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by jcb (Parson)
on Nov 11, 2020 at 00:52 UTC ( [id://11123563]=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 ?

Is there a string conversion overload in Math::GMPz? Perl has quite a few ways to construct overloaded operators from other operators, and one possibility is to first convert the object to a string and then use the builtin string->number conversion.

  • Comment on Re^7: How does Math::GMP overload the assignment operator ? (more guessing)
  • Download Code

Replies are listed 'Best First'.
Re^8: How does Math::GMP overload the assignment operator ? (more guessing)
by syphilis (Archbishop) on Nov 11, 2020 at 01:30 UTC
    one possibility is to first convert the object to a string and then use the builtin string->number conversion

    Yes, that seems consistent with the behaviour I've noticed.
    In the absence of a specified '0+' overload subroutine, $array[Math::GMPz->new(-2)] would be stringified to $array["-2"] and then numified to $array[-2]

    Cheers,
    Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (None)
    As of 2024-04-25 00:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found