Max 5 API Reference
00001 /* 00002 jit.byteorder.c 00003 00004 Copyright 2001-2005 - Cycling '74 00005 Joshua Kit Clayton jkc@cycling74.com 00006 00007 */ 00008 00009 #include "jit.common.h" 00010 00011 /** 00012 * Byte swaps 32 bit floating point number. 00013 * 00014 * @ingroup utilitymod 00015 * 00016 * @param f input float 00017 * 00018 * @return byte swapped float 00019 * 00020 */ 00021 float swapf32(float f){ 00022 unsigned char c,*a; 00023 00024 a = (unsigned char *)&f; 00025 c=a[3]; a[3]=a[0]; a[0]=c; 00026 c=a[2]; a[2]=a[1]; a[1]=c; 00027 00028 return f; 00029 } 00030 00031 00032 /** 00033 * Byte swaps 64 bit floating point number. 00034 * 00035 * @ingroup utilitymod 00036 * 00037 * @param f input double 00038 * 00039 * @return byte swapped double 00040 * 00041 */ 00042 double swapf64(double f){ 00043 unsigned char c,*a; 00044 00045 a = (unsigned char *)&f; 00046 c=a[7]; a[7]=a[0]; a[0]=c; 00047 c=a[6]; a[6]=a[1]; a[1]=c; 00048 c=a[5]; a[5]=a[2]; a[2]=c; 00049 c=a[4]; a[4]=a[3]; a[3]=c; 00050 00051 return f; 00052 }
Copyright © 2008, Cycling '74