/[public]/psiconv/trunk/lib/psiconv/parse_simple.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_simple.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 110 Revision 118
24#include <math.h> 24#include <math.h>
25 25
26#include "parse_routines.h" 26#include "parse_routines.h"
27#include "error.h" 27#include "error.h"
28 28
29/* Very inefficient, but good enough for now. By implementing it ourselves,
30 we do not have to link with -lm */
31psiconv_float_t pow2(int n)
32{
33 psiconv_float_t res=1.0;
34 int i;
35
36 for (i = 0; i < (n<0?-n:n); i++)
37 res *= 2.0;
38
39 return n<0?1/res:res;
40}
29psiconv_u8 psiconv_read_u8(const psiconv_buffer buf,int lev,psiconv_u32 off, 41psiconv_u8 psiconv_read_u8(const psiconv_buffer buf,int lev,psiconv_u32 off,
30 int *status) 42 int *status)
31{ 43{
32 psiconv_u8 *ptr; 44 psiconv_u8 *ptr;
33 ptr = psiconv_buffer_get(buf,off); 45 ptr = psiconv_buffer_get(buf,off);
384 if (res) 396 if (res)
385 goto ERROR; 397 goto ERROR;
386 if (temp & 0x8000) 398 if (temp & 0x8000)
387 result = -result; 399 result = -result;
388 temp = (temp & 0x7ff0) >> 4; 400 temp = (temp & 0x7ff0) >> 4;
389 result *= pow(2.0,((int) temp)-0x3ff); 401 result *= pow2(((int) temp)-0x3ff);
390 psiconv_debug(lev+1,off,"Float value: %f",result); 402 psiconv_debug(lev+1,off,"Float value: %f",result);
391 if (length) 403 if (length)
392 *length = 8; 404 *length = 8;
393 if (*status) 405 if (*status)
394 *status = res; 406 *status = res;
399 *length = 0; 411 *length = 0;
400 if (*status) 412 if (*status)
401 *status = res; 413 *status = res;
402 return 0.0; 414 return 0.0;
403} 415}
416

Legend:
Removed from v.110  
changed lines
  Added in v.118

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26