2bytes 크기의 실수형이란게 있을까요?

doogle의 이미지

보통 PC에서는 실수형데이터를 다루기 위해 Single, Real, Double, Extended정도 사용되는데요. byte 크기는 순서대로, 4bytes, 6bytes, 8bytes, 10bytes.
즉, PC에서 실수형을 담기위해서는 최소 4bytes는 사용됩니다.

그런데 PC이외에 장비나 소형 마이크로칩등에서 비교적 널리 사용하는 2bytes 형태의 실수형이 있는지 알고 싶습니다. (장비to장비, 혹은 장비toPC)

있다면 PC에서 어떻게 decoding(^^;; ) 해야하는지도 알고 싶구요.

구글 검색어라도 ㅜㅜ; float 2bytes 같은걸로는 별 소득이 없네요.

고수님들 답변기다립니다.

cppig1995의 이미지

만들면 있겠죠.
4바이트(float) 6바이트(C에 없음) 8바이트(double) 10바이트 (long double)
이런 것들의 구조를 가지고 만들면 됩니다.
Sign bit, Exponent, Significand 같은 요소들을 적당히 나누어서...

Real programmers /* don't */ comment their code.
If it was hard to write, it should be /* hard to */ read.

doogle의 이미지

제가 만들어 쓰는게 아니고 기존에 있는 장비의 데이터를 가져와야 해서 말이죠.

haze11의 이미지

우선 기존 float나 double의 비트형식을 알아보시고,
입맛에 맞게 만드세요. 없으면 만들면 되죠.
기존 장비와는 형식을 맞춰야겠죠.

사설로.. 예전에 1024bit * 1024bit % 1024bit를
C와 asm으로 구현해보라던 마이크로프로세서 과목이
생각나네요. :)

grassman의 이미지

2바이트라면 앞의 floating point가 아니라 fixed point일 가능성도 있을 듯 한데요. 예를 들어 앞의 1 바이트는 정수부에 뒤의 1바이트는 소숫점 부분으로도 할 수 있죠.

aero의 이미지

2byte라도 IEEE 754 ( http://en.wikipedia.org/wiki/IEEE_754 ) 처럼
적절히 sign bit, exponent, mantissa를 정의해서 사용할것 같네요

2byte floating point number는 IEEE에 의해 표준에 정해진건 없지만
OpenEXR ( http://www.openexr.com/ ) 이 IEEE 제출한 표준안 등등
DSP나 video card등에서 내부적으로 쓰이는 2byte(16bit) floating point 숫자는
sign bit 1, exponent 5, mantissa 10 이렇게 bit를 할당해서 쓴답니다.
http://www.openexr.com/TechnicalIntroduction.pdf 의 12page 설명

The HALF Data Type
Image channels of type HALF are stored as 16-bit floating-point numbers. The 16-bit floating-point data type
is implemented as a C++ class, half, which was designed to behave as much as possible like the standard
floating-point data types built into the C++ language. In arithmetic expressions, numbers of type half can be
mixed freely with float and double numbers; in most cases, conversions to and from half happen
automatically.
half numbers have 1 sign bit, 5 exponent bits, and 10 mantissa bits. The interpretation of the sign, exponent
and mantissa is analogous to IEEE-754 floating-point numbers. half supports normalized and denormalized
numbers, infinities and NANs (Not A Number). The range of representable numbers is roughly 6.0×10-8 -
6.5×104; numbers smaller than 6.1×10-5are denormalized. Conversions from float to half round the
mantissa to 10 bits; the 13 least significant bits are lost. Conversions from half to float are lossless; all
half numbers are exactly representable as float values.
The data type implemented by class half is identical to Nvidia's 16-bit floating-point format
("fp16 / half"). 16-bit data, including infinities and NANs, can be transferred between OpenEXR files
and Nvidia 16-bit floating-point frame buffers without losing any bits.

이걸 기준으로 변환코드를 작성해서 쓰시거나 OpenEXR 안에 해당 숫자를 다루는 코드가 있는것으로 보이니
그것을 사용하셔도 될듯 합니다.

이것말고도 해당시스템이 big endian이냐 little endian 이냐도 고려해야할 사항입니다.

doogle의 이미지

일단 알려주신 정보로 확인해봐야겠네요.
Integer형값들은 Big-Endian WORD형식이라 이것도 고려해봐야겠습니다.

다시한번 도움주셔서 감사합니다. ^-^

익명사용자의 이미지

2바이트 실수 형태는 보통 floating point가 아닌 Q15와 같은 fixed point를 많이 사용합니다.
일반적으로 floating point는 IEEE-754표준에 맞게(포맷만이라도) 배포하는 것이 상례이며, embedded쪽의 fixed point는 지정하기 나름입니다.

댓글 달기

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