/[gxemul]/trunk/src/float_emul.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/float_emul.c

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

revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2004-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 24  Line 24 
24   *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *  $Id: float_emul.c,v 1.5 2005/11/23 22:03:28 debug Exp $   *  $Id: float_emul.c,v 1.9 2006/12/30 13:30:52 debug Exp $
28   *   *
29   *  Floating point emulation routines.   *  Floating point emulation routines.
30   */   */
# Line 142  void ieee_interpret_float_value(uint64_t Line 142  void ieee_interpret_float_value(uint64_t
142          fvp->f = fraction;          fvp->f = fraction;
143    
144  #ifdef IEEE_DEBUG  #ifdef IEEE_DEBUG
145          fatal("{ ieee: x=%016llx sign=%i exponent=%i frac=%f ",          fatal("{ ieee: x=%016"PRIx64" sign=%i exponent=%i frac=%f ",
146              (long long)x, sign, exponent, fraction);              (uint64_t) x, sign, exponent, fraction);
147  #endif  #endif
148    
149          /*  TODO: this is awful for exponents of large magnitude.  */          /*  TODO: this is awful for exponents of large magnitude.  */
# Line 232  uint64_t ieee_store_float_value(double n Line 232  uint64_t ieee_store_float_value(double n
232    
233                  /*                  /*
234                   *  How to convert back from double to exponent + fraction:                   *  How to convert back from double to exponent + fraction:
235                   *  We want fraction to be 1.xxx, that is                   *  The fraction should be 1.xxx, that is
236                   *  1.0 <= fraction < 2.0                   *  1.0 <= fraction < 2.0
237                   *                   *
238                   *  This method is very slow but should work:                   *  This method is very slow but should work:
239                     *  (TODO: Fix the performance problem!)
240                   */                   */
241                  exponent = 0;                  exponent = 0;
242                  while (nf < 1.0 && exponent > -1023) {                  while (nf < 1.0 && exponent > -1023) {
# Line 274  uint64_t ieee_store_float_value(double n Line 275  uint64_t ieee_store_float_value(double n
275                          r = 0;                          r = 0;
276    
277  #ifdef IEEE_DEBUG  #ifdef IEEE_DEBUG
278                  fatal(" exp=%i, r = %016llx }\n", exponent, (long long)r);                  fatal(" exp=%i, r = %016"PRIx64" }\n", exponent, (uint64_t) r);
279  #endif  #endif
280                  break;                  break;
281          default:/*  TODO  */          default:/*  TODO  */

Legend:
Removed from v.20  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26