delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/03/17/13:09:11

From: <ams AT ludd DOT luth DOT se>
Message-Id: <200303171809.h2HI96l03601@speedy.ludd.luth.se>
Subject: Re: strto{d,f,ld}, inf and nan patch
In-Reply-To: <3E736F69.93B74D9C@phekda.freeserve.co.uk> "from Richard Dawe at
Mar 15, 2003 06:22:33 pm"
To: djgpp-workers AT delorie DOT com
Date: Mon, 17 Mar 2003 19:09:06 +0100 (CET)
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
X-MailScanner: Found to be clean
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Richard Dawe:
> The diff didn't seem to include src/libc/c99/math/nan.c.

Oops. It's easy to miss them while they've not been cvs added yet. Now 
we get a test case as well...

Richard shouldn't there be some copyright on the test cases in
tests/libc/c99/?

I'd like to hear some more opinions whether we should accept
"nan(dkjhfd)" or only "nan()".


Right,

						MartinS

Index: djgpp/src/libc/c99/math/nan.c
===================================================================
RCS file: djgpp/src/libc/c99/math/nan.c
diff -N djgpp/src/libc/c99/math/nan.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ djgpp/src/libc/c99/math/nan.c       17 Mar 2003 18:00:24 -0000
@@ -0,0 +1,4 @@
+/* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
+#include <libc/ieee.h>
+
+float_t __dj_nan = { 0x7fffff, 0xff, 0x0 };
Index: djgpp/tests/libc/c99/math/t-nan.c
===================================================================
RCS file: djgpp/tests/libc/c99/math/t-nan.c
diff -N djgpp/tests/libc/c99/math/t-nan.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ djgpp/tests/libc/c99/math/t-nan.c   17 Mar 2003 18:00:39 -0000
@@ -0,0 +1,55 @@
+/*
+ * File t-nan.c.
+ *
+ * Copyright (C) 2003 Martin Str@"omberg <ams AT ludd DOT luth DOT se>.
+ *
+ * This software may be used freely so long as this copyright notice is
+ * left intact. There is no warranty on this software.
+ *
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <libc/ieee.h>
+
+int
+main (void)
+{
+  float f = NAN;
+  double d = NAN;
+  long double ld = NAN;
+
+  if( (*(float_t *)(&f)).exponent == 0xff && (*(float_t *)(&f)).mantissa != 0 )
+  {
+    puts("float = NAN: Ok.");
+  }
+  else
+  {
+    puts("float = NAN: Fail.");
+  }
+
+  if( (*(double_t *)(&d)).exponent == 0x7ff 
+   && ( (*(double_t *)(&d)).mantissah != 0
+     || (*(double_t *)(&d)).mantissal != 0 ) )
+  {
+    puts("double = NAN: Ok.");
+  }
+  else
+  {
+    puts("double = NAN: Fail.");
+  }
+
+  if( (*(long_double_t *)(&ld)).exponent == 0x7fff 
+   && ( (*(long_double_t *)(&ld)).mantissah != 0
+     || (*(long_double_t *)(&ld)).mantissal != 0 ) )
+  {
+    puts("long double = NAN: Ok.");
+  }
+  else
+  {
+    puts("long double = NAN: Fail.");
+  }
+
+  return(EXIT_SUCCESS);
+}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019