C에 대한 질문입니다.

푸르미의 이미지

C에서 int 형이 요즘 보통 32bit인데, 이건 어떤 기준으로 그 size를 정하는건가요? 예전에는 int 가 16bit였는데 말입니다.

그리고 또 하나로는 float이나 double의 기록 방식은 어디서 그 표준을 정한건가요? 또 어디가면 그 기록방식을 알 수 있는지 알고 싶습니다.

call by value, call by reference
pass by value, pass by reference
이런 용어가 있던데 그 의미상 차이는 어떻게 되는건가요?

GunSmoke의 이미지

모든 질문에 대한 답변이 전웅씨의 'C언어 펀더멘탈'에 정확히 기록되어 있습니다. 꼭 읽어보시길...

大逆戰

cinsk의 이미지

표준 문서를 보세요. ;-)

C 언어에서 int의 크기는 정해지지 않았습니다.
궂이 기준이라 한다면 machine에서 지원하는 가장 일반적인 type이라 할까요? C FAQ 참조.

ISO C 표준 6.2.5절 5항 wrote:

An object declared as type signed char occupies the same amount of storage as a plain char object. A plain int object has the natural size suggested by the architecture of the execution environment (large enough to contain any value in the range INT_MIN to INT_MAX as defined in the header <limits.h>).

float이나 double의 기록 방식은 ISO C 표준 (Annex F)에 다음과 같이 나와 있습니다:

  • The float type matches the IEC 60559 single format.
  • The double type matches the IEC 60559 double format.
  • The long double type matches an IEC 60559 extended format,298) else a non-IEC 60559 extended format, else the IEC 60559 double format.
[/]
전웅의 이미지

cinsk wrote:
float이나 double의 기록 방식은 ISO C 표준 (Annex F)에 다음과 같이 나와 있습니다:
  • The float type matches the IEC 60559 single format.
  • The double type matches the IEC 60559 double format.
  • The long double type matches an IEC 60559 extended format,298) else a non-IEC 60559 extended format, else the IEC 60559 double format.

사소한 문제입니다만...

해당 implementation 이 IEEE 754 (지금은 IEC 60559) 를 지원하고, C99
implementation 인 경우에만 적용됩니다.

IEEE 754 의 지원은 C90/C99 모두에서 optional 이며 (C99 는 지원 여부를
알 수 있는 장치를 제공합니다), C90 의 경우 <float.h> section 에서
제시되는 조건만 만족하면 (implementation 이 IEEE 754 를 지원하더라도)
엉뚱한 precision 으로 type 을 대응시킬 수 있습니다.

일반적으로 IEEE 754 지원이 오래 전부터 대세였습니다만, Intel 이나
Motorola 계열을 벗어나면 default mode 에서 IEEE 754 를 지원하지 않는
기종이 종종 있습니다 - 기억이 확실치 않습니다만(!), alpha 가 그랬던
걸로 기억합니다.

[/]

--
Jun, Woong (woong at gmail.com)
http://www.woong.org

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.