⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binary_values.c

📁 spiht的压缩解压缩c编写的
💻 C
字号:
#include "spiht.h"
#include "spihtdecode.h"

int QccBinaryCharToInt(const unsigned char *ch, unsigned int *val)
{
  int byte_cnt;

  if ((val == NULL) || (ch == NULL))
    return(0);

  /*  MSB first  */
  *val = 0;
  for (byte_cnt = 0; byte_cnt < QCC_INT_SIZE; byte_cnt++)
    {
      *val <<= 8;
      *val |= ch[byte_cnt];
    }

  return(0);
}

int QccBinaryIntToChar(unsigned int val, unsigned char *ch)
{
  int byte_cnt;

  if (ch == NULL)
    return(0);

  /*  MSB first  */
  for (byte_cnt = QCC_INT_SIZE - 1; byte_cnt >= 0; byte_cnt--)
    {
      ch[byte_cnt] = (val & 0xff);
      val >>= 8;
    }

  return(0);
}

int QccBinaryCharToFloat(const unsigned char *ch, float *val)
{
  /*  Relies on floats being QCC_INT_SIZE bytes long  */
  union
  {
    float d;
    unsigned int i;
  } tmp;

  if ((val == NULL) || (ch == NULL))
    return(0);

  QccBinaryCharToInt(ch, &(tmp.i));
  *val = tmp.d;

  return(0);
}

int QccBinaryFloatToChar(float val, unsigned char *ch)
{
  /*  Relies on floats being QCC_INT_SIZE bytes long  */
  union
  {
    float d;
    unsigned int i;
  } tmp;

  if (ch == NULL)
    return(0);

  tmp.d = val;
  QccBinaryIntToChar(tmp.i, ch);

  return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -