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

37번째 줄: 37번째 줄:
==Python==
==Python==
[[category: Python]]
[[category: Python]]
{{참고|파이썬 bin()}}
{{참고|파이썬 dec2bin()}}
<source lang='Python'>
<source lang='Python'>
print bin(6)
d = 10
b = f'{decimal:b}'
print( b )
# 1010
print( type(b) )
# <class 'str'>
</source>
<source lang='python'>
d = 10
b = '{0:b}'.format(d)
print( b )
# 1010
print( type(b) )
# <class 'str'>
</source>
<source lang='Python'>
d = 10
b = bin(d)
print( b )
# 0b110
# 0b110
print( type(b) )
# <class 'str'>
</source>
</source>



2019년 11월 13일 (수) 20:30 판

decimal to binary
decbin
bin

1 JavaScript

console.log( 6..toString(2) ); // 110
console.log( 104..toString(2) ); // 1101000
console.log( (+"6").toString(2) ); // 110
console.log( (+"104").toString(2) ); // 1101000
var a = 6;
var b = 104;
console.log( a.toString(2) ); // 110
console.log( b.toString(2) ); // 1101000
var a = "6";
var b = "104";
console.log( (+a).toString(2) ); // 110
console.log( (+b).toString(2) ); // 1101000

2 PHP

echo decbin(6);
// 110

3 Python

d = 10
b = f'{decimal:b}'
print( b )
# 1010
print( type(b) )
# <class 'str'>
d = 10
b = '{0:b}'.format(d)
print( b )
# 1010
print( type(b) )
# <class 'str'>
d = 10
b = bin(d)
print( b )
# 0b110
print( type(b) )
# <class 'str'>

4 같이 보기

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