How to make a custom Number class convertible to int & float?

numbers, python, python-3.x

Solution

From the docs, Emulating Numeric Types:

object.__complex__(self) 
object.__int__(self) 
object.__long__(self) 
object.__float__(self) 

Called to implement the built-in functions complex(), int(), long(), and float(). 
Should return a value of the appropriate type.

Problem

I have implemented a number class in python 3. What do I need to do so that ``` float(mynumber) ``` works correctly?

Original source