C언어에서 int 형이 1WORD 의 크기와 동일한 이유는 무엇일까요?

jouonal의 이미지

C언어에서 int 형이 1WORD 의 크기와 동일한 이유는 무엇일까요?

다른 글을 보니 int형의 최소 크기가 8비트 이고 이는
char <= short <= int 머 이런 규칙에 따라서라는데,,

암튼 int형이 기본적으로(컴파일과 OS제외) CPU가 한번에 처리할수 있는 데이터의 크기인 WORD 크기와 동일 한 이유는 무엇일까요?

제가 생각할때는 int 형이 자료형 중에서 가장 많이 사용되는 자료형이기 때문에 효율적인 처리(char형이나 short형도 처리 할때는 WORD크기로 처리 된다고 알고 있습니다만)
때문이라고 생각하는데 맞는건가요?

익명 사용자의 이미지

int는 프로그램 언어에서 지원하는 primitive type 입니다.

결국 몇 비트로 컴파일 하느냐에 따라 달라집니다.

C/C++에서는 32bit 이거나 64bit 이죠.

하지만 word는 primitive type이 아닙니다.

int가 1word와 동일하다고 하셨는데, 저는 16bit word가 더 흔하다는 생각이 드네요.

windows에서는 DWORD(double word)가 32bit 입니다.

arm에서 word는 보통 thumb instruction 때문인지는 몰라도 16bit를 나타낼때가 더 많습니다.

익명 사용자의 이미지

C/C++에 대해서만 말씀드리자면...

기본적으로 확실히 정해진 것은
char <= short <= int <= long
이 범위 순서와,
각 정수형이 가질 수 있는 최소 범위 뿐입니다. (아래 링크 참조)
http://ko.wikipedia.org/wiki/Limits.h

int가 주로 1 word로 정해진다지만 반드시 그런 것은 아닙니다.
이것이 단적으로 드러난 경우가 64bit 컴퓨터에서의 정수형 모델인데...
http://hellonewworld.tistory.com/78
보다시피 이렇게 다양한 방식이 있고,
각자 장단점이 존재합니다.

그래서 C99에서는 inttype.h에서 int?_t 류의 데이터형을 따로 정의하게 된 것이죠.

그리고 word 단위는 참 뭐라고 딱 잘라 말하기가 어렵습니다.
http://en.wikipedia.org/wiki/Word_(computer_architecture)
크기도 제각각이고 여기저기서 편한대로 서로다른 의미로 쓰는 단어라서...

cinsk의 이미지

int의 최소 크기는 16bit입니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.