prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  decimal_to_binary() should return identical values as bin()
  https://github.com/TheAlgorithms/Python/blob/7b267e5e4f8ccb72dd58fcf0057642fd62a36bdf/conversions/decimal_to_binary.py#L4
  
  Please change __decimal_to_binary()__ to return identical values as the Python builtin [__bin()__](https://docs.python.org/3/library/functions.html#bin).  With doctests to prove it please.
  
  @PatOnTheBack @Corruption13
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `conversions/decimal_to_binary.py`
  Content:
  ```
  1 """Convert a Decimal Number to a Binary Number."""
  2 
  3 
  4 def decimal_to_binary(num):
  5     """Convert a Decimal Number to a Binary Number."""
  6     binary = []
  7     while num > 0:
  8         binary.insert(0, num % 2)
  9         num >>= 1
  10     return "".join(str(e) for e in binary)
  11 
  12 
  13 def main():
  14     """Print binary equivelents of decimal numbers."""
  15     print("\n2 in binary is:")
  16     print(decimal_to_binary(2))  # = 10
  17     print("\n7 in binary is:")
  18     print(decimal_to_binary(7))  # = 111
  19     print("\n35 in binary is:")
  20     print(decimal_to_binary(35))  # = 100011
  21     print("\n")
  22 
  23 
  24 if __name__ == '__main__':
  25     main()
  26
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/conversions/decimal_to_binary.py b/conversions/decimal_to_binary.py
  --- a/conversions/decimal_to_binary.py
  +++ b/conversions/decimal_to_binary.py
  @@ -2,24 +2,57 @@
   
   
   def decimal_to_binary(num):
  -    """Convert a Decimal Number to a Binary Number."""
  +
  +    """
  +        Convert a Integer Decimal Number to a Binary Number as str.
  +        >>> decimal_to_binary(0)
  +        '0b0'
  +        >>> decimal_to_binary(2)
  +        '0b10'
  +        >>> decimal_to_binary(7)
  +        '0b111'
  +        >>> decimal_to_binary(35)
  +        '0b100011'
  +        >>> # negatives work too
  +        >>> decimal_to_binary(-2)
  +        '-0b10'
  +        >>> # other floats will error
  +        >>> decimal_to_binary(16.16) # doctest: +ELLIPSIS
  +        Traceback (most recent call last):
  +        ...
  +        TypeError: 'float' object cannot be interpreted as an integer
  +        >>> # strings will error as well
  +        >>> decimal_to_binary('0xfffff') # doctest: +ELLIPSIS
  +        Traceback (most recent call last):
  +        ...
  +        TypeError: 'str' object cannot be interpreted as an integer
  +    """
  +
  +    if type(num) == float:
  +        raise TypeError("'float' object cannot be interpreted as an integer")
  +    if type(num) == str:
  +        raise TypeError("'str' object cannot be interpreted as an integer")
  +
  +    if num == 0:
  +        return "0b0"
  +
  +    negative = False
  +
  +    if num < 0:
  +        negative = True
  +        num = -num
  +
       binary = []
       while num > 0:
           binary.insert(0, num % 2)
           num >>= 1
  -    return "".join(str(e) for e in binary)
   
  +    if negative:
  +        return "-0b" + "".join(str(e) for e in binary)
   
  -def main():
  -    """Print binary equivelents of decimal numbers."""
  -    print("\n2 in binary is:")
  -    print(decimal_to_binary(2))  # = 10
  -    print("\n7 in binary is:")
  -    print(decimal_to_binary(7))  # = 111
  -    print("\n35 in binary is:")
  -    print(decimal_to_binary(35))  # = 100011
  -    print("\n")
  +    return "0b" + "".join(str(e) for e in binary)
   
   
  -if __name__ == '__main__':
  -    main()
  +if __name__ == "__main__":
  +    import doctest
  +    doctest.testmod()
  
verification_info: {"golden_diff": "diff --git a/conversions/decimal_to_binary.py b/conversions/decimal_to_binary.py\n--- a/conversions/decimal_to_binary.py\n+++ b/conversions/decimal_to_binary.py\n@@ -2,24 +2,57 @@\n \n \n def decimal_to_binary(num):\n-    \"\"\"Convert a Decimal Number to a Binary Number.\"\"\"\n+\n+    \"\"\"\n+        Convert a Integer Decimal Number to a Binary Number as str.\n+        >>> decimal_to_binary(0)\n+        '0b0'\n+        >>> decimal_to_binary(2)\n+        '0b10'\n+        >>> decimal_to_binary(7)\n+        '0b111'\n+        >>> decimal_to_binary(35)\n+        '0b100011'\n+        >>> # negatives work too\n+        >>> decimal_to_binary(-2)\n+        '-0b10'\n+        >>> # other floats will error\n+        >>> decimal_to_binary(16.16) # doctest: +ELLIPSIS\n+        Traceback (most recent call last):\n+        ...\n+        TypeError: 'float' object cannot be interpreted as an integer\n+        >>> # strings will error as well\n+        >>> decimal_to_binary('0xfffff') # doctest: +ELLIPSIS\n+        Traceback (most recent call last):\n+        ...\n+        TypeError: 'str' object cannot be interpreted as an integer\n+    \"\"\"\n+\n+    if type(num) == float:\n+        raise TypeError(\"'float' object cannot be interpreted as an integer\")\n+    if type(num) == str:\n+        raise TypeError(\"'str' object cannot be interpreted as an integer\")\n+\n+    if num == 0:\n+        return \"0b0\"\n+\n+    negative = False\n+\n+    if num < 0:\n+        negative = True\n+        num = -num\n+\n     binary = []\n     while num > 0:\n         binary.insert(0, num % 2)\n         num >>= 1\n-    return \"\".join(str(e) for e in binary)\n \n+    if negative:\n+        return \"-0b\" + \"\".join(str(e) for e in binary)\n \n-def main():\n-    \"\"\"Print binary equivelents of decimal numbers.\"\"\"\n-    print(\"\\n2 in binary is:\")\n-    print(decimal_to_binary(2))  # = 10\n-    print(\"\\n7 in binary is:\")\n-    print(decimal_to_binary(7))  # = 111\n-    print(\"\\n35 in binary is:\")\n-    print(decimal_to_binary(35))  # = 100011\n-    print(\"\\n\")\n+    return \"0b\" + \"\".join(str(e) for e in binary)\n \n \n-if __name__ == '__main__':\n-    main()\n+if __name__ == \"__main__\":\n+    import doctest\n+    doctest.testmod()\n", "issue": "decimal_to_binary() should return identical values as bin()\nhttps://github.com/TheAlgorithms/Python/blob/7b267e5e4f8ccb72dd58fcf0057642fd62a36bdf/conversions/decimal_to_binary.py#L4\r\n\r\nPlease change __decimal_to_binary()__ to return identical values as the Python builtin [__bin()__](https://docs.python.org/3/library/functions.html#bin).  With doctests to prove it please.\r\n\r\n@PatOnTheBack @Corruption13\n", "before_files": [{"content": "\"\"\"Convert a Decimal Number to a Binary Number.\"\"\"\n\n\ndef decimal_to_binary(num):\n    \"\"\"Convert a Decimal Number to a Binary Number.\"\"\"\n    binary = []\n    while num > 0:\n        binary.insert(0, num % 2)\n        num >>= 1\n    return \"\".join(str(e) for e in binary)\n\n\ndef main():\n    \"\"\"Print binary equivelents of decimal numbers.\"\"\"\n    print(\"\\n2 in binary is:\")\n    print(decimal_to_binary(2))  # = 10\n    print(\"\\n7 in binary is:\")\n    print(decimal_to_binary(7))  # = 111\n    print(\"\\n35 in binary is:\")\n    print(decimal_to_binary(35))  # = 100011\n    print(\"\\n\")\n\n\nif __name__ == '__main__':\n    main()\n", "path": "conversions/decimal_to_binary.py"}], "after_files": [{"content": "\"\"\"Convert a Decimal Number to a Binary Number.\"\"\"\n\n\ndef decimal_to_binary(num):\n\n    \"\"\"\n        Convert a Integer Decimal Number to a Binary Number as str.\n        >>> decimal_to_binary(0)\n        '0b0'\n        >>> decimal_to_binary(2)\n        '0b10'\n        >>> decimal_to_binary(7)\n        '0b111'\n        >>> decimal_to_binary(35)\n        '0b100011'\n        >>> # negatives work too\n        >>> decimal_to_binary(-2)\n        '-0b10'\n        >>> # other floats will error\n        >>> decimal_to_binary(16.16) # doctest: +ELLIPSIS\n        Traceback (most recent call last):\n        ...\n        TypeError: 'float' object cannot be interpreted as an integer\n        >>> # strings will error as well\n        >>> decimal_to_binary('0xfffff') # doctest: +ELLIPSIS\n        Traceback (most recent call last):\n        ...\n        TypeError: 'str' object cannot be interpreted as an integer\n    \"\"\"\n\n    if type(num) == float:\n        raise TypeError(\"'float' object cannot be interpreted as an integer\")\n    if type(num) == str:\n        raise TypeError(\"'str' object cannot be interpreted as an integer\")\n\n    if num == 0:\n        return \"0b0\"\n\n    negative = False\n\n    if num < 0:\n        negative = True\n        num = -num\n\n    binary = []\n    while num > 0:\n        binary.insert(0, num % 2)\n        num >>= 1\n\n    if negative:\n        return \"-0b\" + \"\".join(str(e) for e in binary)\n\n    return \"0b\" + \"\".join(str(e) for e in binary)\n\n\nif __name__ == \"__main__\":\n    import doctest\n    doctest.testmod()\n", "path": "conversions/decimal_to_binary.py"}]}