+ 1
How to convert any integer number to hexadecimal number?
Please explain it in a easy way & give some example
11 odpowiedzi
+ 11
[Python]
You can just use hex().
To convert a string to base 10 from another base you can use the second parameter of int().
print(hex(255)) # output 0xff
print(int("ff", 16)) # output 255
or using input():
print(hex(int(input())))
print(int(input(), 16)) # inputting ff or 0xff gives same result
+ 9
In python, Hex numbers can also be created for output with print() and format string:
inp = 200
print(f'dec: {inp:3d}, hex: {inp:3X}')
# output: dec: 200, hex: C8
# or a string can be generated for further use:
h_res = f'{inp:X}'
# h_res : 'C8'
+ 9
Lothar he is asking in c language ....🤣
+ 9
Oma Falk 😅🤣🤣 he mention in tag so
+ 6
divide by 16 and write down rest.
200
200/16 = 12 remainder 8
12/16 = 0 remainder 12 aka c
result c8
+ 5
🐍(💖Sizuna 💖)🐉 how do u know?
+ 4
🐍(💖Sizuna 💖)🐉 ahhh he added
+ 3
blackwinter nice!
+ 1
Martin Taylor
0
Divide that number by it's base which is 16..as we do for converting decimal to binary since the base of binary is 2 that's why we divide it by 2...do the same for it also..use base 16 instead of 2