-1

I develop an application for seismic data processing in C++. I have a file with seismic data in F2 BGN format. F2 BGN 16-bit format is 1 bit - sign, 11 bits - amplitude, 4 bits - gain. I can convert F2 BGN to IEEE-754 float this way: (mantissa / (2 ** 10)) * 2 ** (15 - gain), where mantissa is the first 12 bits. I think this is some "ancient" format. It seems like a half-float format. If somebody knows how to do the conversion (I understand there is a loss of precision) or if somebody knows about documentation, please tell me. Thanks in advance.

Ghasem Ramezani
  • 2,683
  • 1
  • 13
  • 32
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 08 '21 at 09:38
  • I want to know how to convert float number to F2 BGN 16-bit format (described above). I can extract mantissa and exponent from float number but what should I do next with them I don't understand. I don't know what mean "amplitude" and "gain" in F2 BGN format (maybe mantissa and exponent? I am not sure). I have no more information about this format except what I described above. – Дмитрий Sep 14 '21 at 14:49

1 Answers1

1

This post contains a list of 16 bit implementations in C++: https://stackoverflow.com/a/56016178/16792184.

If that doesn't work for you, you can always use the C++ bitset (https://en.cppreference.com/w/cpp/utility/bitset) and define your own 16 bit half-precision type using it.

Nullpoint
  • 53
  • 8