ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/portio.c
(Generate patch)

Comparing ray/src/common/portio.c (file contents):
Revision 2.12 by greg, Fri Feb 18 16:34:27 2005 UTC vs.
Revision 2.14 by greg, Sat Dec 23 17:27:45 2006 UTC

# Line 4 | Line 4 | static const char      RCSid[] = "$Id$";
4   /*
5   * Portable i/o for binary files
6   *
7 < * External symbols declared in standard.h
7 > * External symbols declared in rtio.h
8   */
9  
10   #include "copyright.h"
11  
12 #include <stdio.h>
13
12   #include "rtio.h"
13  
14   #include <math.h>
# Line 50 | Line 48 | putflt(f, fp)                  /* put out floating point number */
48   double  f;
49   FILE  *fp;
50   {
51 +        long  m;
52          int  e;
53  
54 <        putint((long)(frexp(f,&e)*0x7fffffff), 4, fp);
54 >        m = frexp(f, &e) * 0x7fffffff;
55 >        if (e > 127) {                  /* overflow */
56 >                m = m > 0 ? (long)0x7fffffff : -(long)0x7fffffff;
57 >                e = 127;
58 >        } else if (e < -128) {          /* underflow */
59 >                m = 0;
60 >                e = 0;
61 >        }
62 >        putint(m, 4, fp);
63          putint((long)e, 1, fp);
64   }
65  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines