"함수 dechex()"의 두 판 사이의 차이

11번째 줄: 11번째 줄:
==Bash==
==Bash==
[[category: Bash]]
[[category: Bash]]
<syntaxhighlight lang='Bash'>
<syntaxhighlight lang='Bash' run>
printf %x 10
printf %x 10   # a
# a
printf %x 47   # 2f
printf %x 47
printf %x 65535 # ffff
# 2f
printf %x 65535
# ffff
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='Bash'>
<syntaxhighlight lang='Bash'>

2021년 4월 21일 (수) 23:24 판


1 개요

hex
dechex()
.toHexString()
  • decimal to hexadecimal
  • 10진수 → 16진수

2 Bash

printf %x 10    # a
printf %x 47    # 2f
printf %x 65535 # ffff
result=`printf %x 65535`
echo $result
# ffff
echo "obase=16; 10" | bc
# A
echo "obase=16; 47" | bc
# 2F
echo "obase=16; 65535" | bc
# FFFF

3 Java

System.out.println( Integer.toHexString(10) );
System.out.println( Integer.toHexString(47) );
System.out.println( Integer.toHexString(65535) );
// a
// 2f
// ffff
System.out.println( Long.toHexString(4294967295L) );
System.out.println( Long.toHexString(1234567890123456L) );
// ffffffff
// 462d53c8abac0

4 PHP

echo dechex(10)    . "\n"; # a
echo dechex(47)    . "\n"; # 2f
echo dechex(65535) . "\n"; # ffff

5 Python

print( hex(10) )    # 0xa
print( hex(47) )    # 0x2f
print( hex(65535) ) # 0xffff

6 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}