목록10진수 (1)
YOGYUI
Python - 음의 정수를 16진수로 표현하기 (negative int to hex)
Python 내장함수인 hex는 정수값을 16진수로 표현된 문자열(str)을 반환해준다 help(hex) >> Help on built-in function hex in module builtins: hex(number, /) Return the hexadecimal representation of an integer. hex(12648430) '0xc0ffee' In [1]: hex(25) Out[1]: '0x19' In [2]: hex(1234) Out[2]: '0x4d2' 그런데, 함수의 인자로 음의 정수 (negative integer)를 입력하면 다른 프로그래밍 언어에서와는 다른 결과가 출력된다 In [3]: hex(-1) Out[3]: '-0x1' In [4]: hex(-128) Out[4]:..
Software/Python
2021. 8. 24. 14:31