~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to libguile/numbers.c

  • Committer: Bazaar Package Importer
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2009-07-20 19:39:17 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090720193917-s0985l9wxihwoscl
Tags: 1.8.7+1-1ubuntu1
* Merge from Debian unstable, remaining changes: (LP: #401816)
  - Build with -Wno-error.
  - Build with thread support. Some guile-using programs like autogen need it.
  - Add debian/guile-1.8-libs.shlibs: Thread support breaks ABI, bump the soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
1
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
2
2
 *
3
3
 * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories
4
4
 * and Bellcore.  See scm_divide.
637
637
 
638
638
#if defined (HAVE_ISNAN)
639
639
 
 
640
#if defined __GNUC__ && defined __alpha__ && !defined _IEEE_FP
 
641
  /* On Alpha GCC must be passed `-mieee' to provide proper NaN handling.
 
642
     See http://lists.gnu.org/archive/html/bug-gnulib/2009-05/msg00010.html
 
643
     for more details.  */
 
644
# error NaN handling will not work when compiling without -mieee
 
645
#endif
 
646
 
640
647
#ifdef NAN
641
648
  /* C99 NAN, when available */
642
649
  guile_NaN = NAN;
2732
2739
  unsigned int idx = *p_idx;
2733
2740
  SCM result;
2734
2741
 
 
2742
  /* Start off believing that the number will be exact.  This changes
 
2743
     to INEXACT if we see a decimal point or a hash. */
 
2744
  enum t_exactness x = EXACT;
 
2745
 
2735
2746
  if (idx == len)
2736
2747
    return SCM_BOOL_F;
2737
2748
 
2743
2754
 
2744
2755
  if (idx+4 < len && !strncmp (mem+idx, "nan.", 4))
2745
2756
    {
2746
 
      enum t_exactness x = EXACT;
2747
 
 
2748
2757
      /* Cobble up the fractional part.  We might want to set the
2749
2758
         NaN's mantissa from it. */
2750
2759
      idx += 4;
2763
2772
        return SCM_BOOL_F;
2764
2773
      else
2765
2774
        result = mem2decimal_from_point (SCM_I_MAKINUM (0), mem, len,
2766
 
                                         p_idx, p_exactness);
 
2775
                                         p_idx, &x);
2767
2776
    }
2768
2777
  else
2769
2778
    {
2770
 
      enum t_exactness x = EXACT;
2771
2779
      SCM uinteger;
2772
2780
 
2773
2781
      uinteger = mem2uinteger (mem, len, &idx, radix, &x);
2799
2807
        result = uinteger;
2800
2808
 
2801
2809
      *p_idx = idx;
2802
 
      if (x == INEXACT)
2803
 
        *p_exactness = x;
2804
2810
    }
2805
2811
 
 
2812
  /* Update *p_exactness if the number just read was inexact.  This is
 
2813
     important for complex numbers, so that a complex number is
 
2814
     treated as inexact overall if either its real or imaginary part
 
2815
     is inexact.
 
2816
  */
 
2817
  if (x == INEXACT)
 
2818
    *p_exactness = x;
 
2819
 
2806
2820
  /* When returning an inexact zero, make sure it is represented as a
2807
2821
     floating point value so that we can change its sign. 
2808
2822
  */
5352
5366
scm_c_make_polar (double mag, double ang)
5353
5367
{
5354
5368
  double s, c;
5355
 
#if HAVE_SINCOS
 
5369
 
 
5370
  /* The sincos(3) function is undocumented an broken on Tru64.  Thus we only
 
5371
     use it on Glibc-based systems that have it (it's a GNU extension).  See
 
5372
     http://lists.gnu.org/archive/html/guile-user/2009-04/msg00033.html for
 
5373
     details.  */
 
5374
#if (defined HAVE_SINCOS) && (defined __GLIBC__) && (defined _GNU_SOURCE)
5356
5375
  sincos (ang, &s, &c);
5357
5376
#else
5358
5377
  s = sin (ang);