csendian.h File Reference
Helpers for dealing with endian conversions. More...
#include <math.h>
#include "cstypes.h"
Go to the source code of this file.
Classes | |
struct | csEndianSwap4 |
struct | csEndianSwap8 |
Floating point conversions | |
The following routines are used for converting floating-point numbers into 16-bit shorts and back. This is useful for low-precision data. They use the 1.4.12 format. The range of numbers that can be represented in this format is from 2^-8 to 2^7. The precision for numbers near to 2^-8 (0.00390625) is near 0.000001, for numbers near 2^7 (128) is near 0.03. | |
static short | csFloatToShort (float f) |
Convert a float to a cross-platform 16-bit format (no endianess adjustments!). | |
static float | csShortToFloat (short s) |
Convert a 16-bit cross-platform float to native format (no endianess adjustments!). | |
Defines | |
#define | csQroundSure(x) (int ((x) + ((x < 0) ? -0.5 : +0.5))) |
Functions | |
static float | csBigEndianFloat (float f) |
Convert a big-endian floating-point number to machine format. | |
static uint32 | csBigEndianLong (uint32 l) |
Convert a long from big-endian to machine format. | |
static uint64 | csBigEndianLongLong (uint64 l) |
Convert a longlong from big-endian to machine format. | |
static uint16 | csBigEndianShort (uint16 s) |
Convert a short from big-endian to machine format. | |
static float | csConvertEndian (float f) |
Swap the bytes in a float value. | |
static uint16 | csConvertEndian (uint16 s) |
Swap the bytes in a uint16 value. | |
static int16 | csConvertEndian (int16 s) |
Swap the bytes in a int16 value. | |
static int32 | csConvertEndian (int32 l) |
Swap the bytes in a int32 value. | |
static uint32 | csConvertEndian (uint32 l) |
Swap the bytes in a uint32 value. | |
static int64 | csConvertEndian (int64 l) |
Swap the bytes in a int64 value. | |
static uint64 | csConvertEndian (uint64 l) |
Swap the bytes in a uint64 value. | |
static int64 | csDoubleToLongLong (double d) |
Convert a double to a cross-platform 64-bit format (no endianess adjustments!). | |
static int32 | csFloatToLong (float f) |
Convert a float to a cross-platform 32-bit format (no endianess adjustments!). | |
float | csGetBigEndianFloat16 (const void *buff) |
Read a big-endian 16-bit float from address. | |
float | csGetBigEndianFloat32 (const void *buff) |
Read a big-endian 32-bit float from address. | |
uint32 | csGetBigEndianLong (const void *buff) |
Read a big-endian long from address. | |
uint16 | csGetBigEndianShort (const void *buff) |
Read a big-endian short from address. | |
float | csGetLittleEndianFloat16 (const void *buff) |
Read a little-endian 16-bit float from address. | |
float | csGetLittleEndianFloat32 (const void *buff) |
Read a little-endian 32-bit float from address. | |
uint32 | csGetLittleEndianLong (const void *buff) |
Read a little-endian long from address. | |
uint16 | csGetLittleEndianShort (const void *buff) |
Read a little-endian short from address. | |
static float | csLittleEndianFloat (float f) |
Convert a little-endian floating-point number to machine format. | |
static uint32 | csLittleEndianLong (uint32 l) |
Convert a long from little-endian to machine format. | |
static uint64 | csLittleEndianLongLong (uint64 l) |
Convert a longlong from little-endian to machine format. | |
static uint16 | csLittleEndianShort (uint16 s) |
Convert a short from little-endian to machine format. | |
static double | csLongLongToDouble (int64 i) |
Convert a 64-bit cross-platform double to native format (no endianess adjustments!). | |
static float | csLongToFloat (int32 l) |
Convert a 32-bit cross-platform float to native format (no endianess adjustments!). | |
void | csSetBigEndianFloat16 (void *buff, float f) |
Set a big-endian 16-bit float on a address. | |
void | csSetBigEndianFloat32 (void *buff, float f) |
Set a big-endian 32-bit float on a address. | |
void | csSetBigEndianLong (void *buff, uint32 l) |
Set a big-endian long on a address. | |
void | csSetBigEndianShort (void *buff, uint16 s) |
Set a big-endian short on a address. | |
void | csSetLittleEndianFloat16 (void *buff, float f) |
Set a little-endian 16-bit float on a address. | |
void | csSetLittleEndianFloat32 (void *buff, float f) |
Set a little-endian 32-bit float on a address. | |
void | csSetLittleEndianLong (void *buff, uint32 l) |
Set a little-endian long on a address. | |
void | csSetLittleEndianShort (void *buff, uint16 s) |
Set a little-endian short on a address. |
Detailed Description
Helpers for dealing with endian conversions.
Definition in file csendian.h.
Function Documentation
|
Swap the bytes in a float value.
Definition at line 262 of file csendian.h. References csLittleEndianFloat(). |
|
Swap the bytes in a uint16 value.
Definition at line 258 of file csendian.h. References csLittleEndianShort(). |
|
Swap the bytes in a int16 value.
Definition at line 254 of file csendian.h. References csLittleEndianShort(). |
|
Swap the bytes in a int32 value.
Definition at line 250 of file csendian.h. References csLittleEndianLong(). |
|
Swap the bytes in a uint32 value.
Definition at line 246 of file csendian.h. References csLittleEndianLong(). |
|
Swap the bytes in a int64 value.
Definition at line 242 of file csendian.h. References csLittleEndianLongLong(). |
|
Swap the bytes in a uint64 value.
Definition at line 238 of file csendian.h. References csLittleEndianLongLong(). |
|
Convert a float to a cross-platform 16-bit format (no endianess adjustments!).
Definition at line 215 of file csendian.h. References csQroundSure. Referenced by csSetBigEndianFloat16(), and csSetLittleEndianFloat16(). |
|
Read a big-endian 16-bit float from address.
Definition at line 353 of file csendian.h. References csGetBigEndianShort(), and csShortToFloat(). |
|
Read a big-endian 32-bit float from address.
Definition at line 349 of file csendian.h. References csGetBigEndianLong(), and csLongToFloat(). |
|
Read a big-endian long from address.
Definition at line 338 of file csendian.h. References csBigEndianLong(). Referenced by csGetBigEndianFloat32(). |
|
Read a big-endian short from address.
Definition at line 327 of file csendian.h. References csBigEndianShort(). Referenced by csGetBigEndianFloat16(). |
|
Read a little-endian 16-bit float from address.
Definition at line 292 of file csendian.h. References csGetLittleEndianShort(), and csShortToFloat(). |
|
Read a little-endian 32-bit float from address.
Definition at line 288 of file csendian.h. References csGetLittleEndianLong(), and csLongToFloat(). |
|
Read a little-endian long from address.
Definition at line 277 of file csendian.h. References csLittleEndianLong(). Referenced by csGetLittleEndianFloat32(). |
|
Read a little-endian short from address.
Definition at line 266 of file csendian.h. References csLittleEndianShort(). Referenced by csGetLittleEndianFloat16(). |
|
Set a big-endian 16-bit float on a address.
Definition at line 383 of file csendian.h. References csFloatToShort(), and csSetBigEndianShort(). |
|
Set a big-endian 32-bit float on a address.
Definition at line 379 of file csendian.h. References csFloatToLong(), and csSetBigEndianLong(). |
|
Set a big-endian long on a address.
Definition at line 368 of file csendian.h. References csBigEndianLong(). Referenced by csSetBigEndianFloat32(). |
|
Set a big-endian short on a address.
Definition at line 357 of file csendian.h. References csBigEndianShort(). Referenced by csSetBigEndianFloat16(). |
|
Set a little-endian 16-bit float on a address.
Definition at line 322 of file csendian.h. References csFloatToShort(), and csSetLittleEndianShort(). |
|
Set a little-endian 32-bit float on a address.
Definition at line 318 of file csendian.h. References csFloatToLong(), and csSetLittleEndianLong(). |
|
Set a little-endian long on a address.
Definition at line 307 of file csendian.h. References csLittleEndianLong(). Referenced by csSetLittleEndianFloat32(). |
|
Set a little-endian short on a address.
Definition at line 296 of file csendian.h. References csLittleEndianShort(). Referenced by csSetLittleEndianFloat16(). |
|
Convert a 16-bit cross-platform float to native format (no endianess adjustments!).
Definition at line 226 of file csendian.h. Referenced by csGetBigEndianFloat16(), and csGetLittleEndianFloat16(). |
Generated for Crystal Space by doxygen 1.4.4