![]() The solution is to simply tweak the conversion to integer a bit. Running a simple conversion using the bin() function renders a TypeError exception: bin (my_hex) T ypeError: 'str' object cannot be interpreted as an integerĬonverting the hexadecimal to integer, and then converting to binary also renders an error: bin (int(my_hex)) ValueError: invalid literal for int() with base 10: '0x200' Change hexadecimal to binary Let’s assume that we have the following hexadecimal (which represent the integer value 512) my_hex = '0x200' ![]() ![]() We would like to convert an hexadecimal number to a binary number system (or from base 16 to base 2).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |