Table of Contents

NAME

QccBinaryCharToInt, QccBinaryIntToChar, QccBinaryCharToFloat, QccBinaryFloatToChar - convert integers and floating-point values into character arrays

SYNOPSIS

#include "libQccPack.h"

#define QCC_INT_SIZE 4

int QccBinaryCharToInt(const unsigned char *ch, unsigned int *val);
int QccBinaryIntToChar(unsigned int val, unsigned char *ch);
int QccBinaryCharToFloat(const unsigned char *ch, float *val);
int QccBinaryFloatToChar(float val, unsigned char *ch);

DESCRIPTION

All binary-valued numbers stored to files by QccPack have their most-significant byte (MSB) written first. However, whether the host computer stores binary values in MSB-first (Big Endian) or LSB-first (Little Endian) format depends on the architecture of machine. These routines convert between the MSB-first values used in QccPack files and int or float values with the host byte order. Thus, files written by QccPack programs should then be portable across different architectures.

For each of the routines, ch is an array of characters containing QCC_INT_SIZE bytes.

QccBinaryCharToInt() converts a MSB-first QCC_INT_SIZE-length character array to an int. QccBinaryIntToChar() converts an int to a MSB-first QCC_INT_SIZE-length character array.

QccBinaryCharToFloat() converts a MSB-first QCC_INT_SIZE-length character array to an float. QccBinaryFloatToChar() converts an float to a MSB-first QCC_INT_SIZE-length character array.

SEE ALSO

QccPack(3)

NOTES

These routines rely on int and float values being QCC_INT_SIZE (four) bytes long (i.e., 32-bit values). Although it seems that this is the case for modern computer systems, some 64-bit systems might use longer values.

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads