source: trunk/sys/libm/k_standard.c @ 436

Last change on this file since 436 was 1, checked in by alain, 7 years ago

First import

File size: 18.3 KB
Line 
1
2/* @(#)k_standard.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
12 *
13 */
14
15#include <libm/fdlibm.h>
16#include <errno.h>
17
18#ifndef _USE_WRITE
19#include <stdio.h>                      /* fputs(), stderr */
20#define WRITE2(u,v)     fputs(u, stderr)
21#else   /* !defined(_USE_WRITE) */
22#include <unistd.h>                     /* write */
23#define WRITE2(u,v)     write(2, u, v)
24#undef fflush
25#endif  /* !defined(_USE_WRITE) */
26
27static double zero = 0.0;       /* used as const */
28
29/*
30 * Standard conformance (non-IEEE) on exception cases.
31 * Mapping:
32 *      1 -- acos(|x|>1)
33 *      2 -- asin(|x|>1)
34 *      3 -- atan2(+-0,+-0)
35 *      4 -- hypot overflow
36 *      5 -- cosh overflow
37 *      6 -- exp overflow
38 *      7 -- exp underflow
39 *      8 -- y0(0)
40 *      9 -- y0(-ve)
41 *      10-- y1(0)
42 *      11-- y1(-ve)
43 *      12-- yn(0)
44 *      13-- yn(-ve)
45 *      14-- lgamma(finite) overflow
46 *      15-- lgamma(-integer)
47 *      16-- log(0)
48 *      17-- log(x<0)
49 *      18-- log10(0)
50 *      19-- log10(x<0)
51 *      20-- pow(0.0,0.0)
52 *      21-- pow(x,y) overflow
53 *      22-- pow(x,y) underflow
54 *      23-- pow(0,negative)
55 *      24-- pow(neg,non-integral)
56 *      25-- sinh(finite) overflow
57 *      26-- sqrt(negative)
58 *      27-- fmod(x,0)
59 *      28-- remainder(x,0)
60 *      29-- acosh(x<1)
61 *      30-- atanh(|x|>1)
62 *      31-- atanh(|x|=1)
63 *      32-- scalb overflow
64 *      33-- scalb underflow
65 *      34-- j0(|x|>X_TLOSS)
66 *      35-- y0(x>X_TLOSS)
67 *      36-- j1(|x|>X_TLOSS)
68 *      37-- y1(x>X_TLOSS)
69 *      38-- jn(|x|>X_TLOSS, n)
70 *      39-- yn(x>X_TLOSS, n)
71 *      40-- gamma(finite) overflow
72 *      41-- gamma(-integer)
73 *      42-- pow(NaN,0.0)
74 */
75
76
77#ifdef __STDC__
78        double __kernel_standard(double x, double y, int type) 
79#else
80        double __kernel_standard(x,y,type) 
81        double x,y; int type;
82#endif
83{
84        struct exception exc;
85#ifndef HUGE_VAL        /* this is the only routine that uses HUGE_VAL */ 
86#define HUGE_VAL inf
87        double one = 1.0, inf = 0.0;
88        int i0;
89
90        i0 = ((*(int*)&one)>>29)^1;
91        *(i0+(int*)&inf) = 0x7ff00000;  /* set inf to infinite */
92#endif
93
94#ifdef _USE_WRITE
95        (void) fflush(stdout);
96#endif
97        exc.arg1 = x;
98        exc.arg2 = y;
99        switch(type) {
100            case 1:
101                /* acos(|x|>1) */
102                exc.type = DOMAIN;
103                exc.name = "acos";
104                exc.retval = zero;
105                if (_LIB_VERSION == _POSIX_)
106                  errno = EDOM;
107                else if (!matherr(&exc)) {
108                  if(_LIB_VERSION == _SVID_) {
109                    (void) WRITE2("acos: DOMAIN error\n", 19);
110                  }
111                  errno = EDOM;
112                }
113                break;
114            case 2:
115                /* asin(|x|>1) */
116                exc.type = DOMAIN;
117                exc.name = "asin";
118                exc.retval = zero;
119                if(_LIB_VERSION == _POSIX_)
120                  errno = EDOM;
121                else if (!matherr(&exc)) {
122                  if(_LIB_VERSION == _SVID_) {
123                        (void) WRITE2("asin: DOMAIN error\n", 19);
124                  }
125                  errno = EDOM;
126                }
127                break;
128            case 3:
129                /* atan2(+-0,+-0) */
130                exc.arg1 = y;
131                exc.arg2 = x;
132                exc.type = DOMAIN;
133                exc.name = "atan2";
134                exc.retval = zero;
135                if(_LIB_VERSION == _POSIX_)
136                  errno = EDOM;
137                else if (!matherr(&exc)) {
138                  if(_LIB_VERSION == _SVID_) {
139                        (void) WRITE2("atan2: DOMAIN error\n", 20);
140                      }
141                  errno = EDOM;
142                }
143                break;
144            case 4:
145                /* hypot(finite,finite) overflow */
146                exc.type = OVERFLOW;
147                exc.name = "hypot";
148                if (_LIB_VERSION == _SVID_)
149                  exc.retval = HUGE;
150                else
151                  exc.retval = HUGE_VAL;
152                if (_LIB_VERSION == _POSIX_)
153                  errno = ERANGE;
154                else if (!matherr(&exc)) {
155                        errno = ERANGE;
156                }
157                break;
158            case 5:
159                /* cosh(finite) overflow */
160                exc.type = OVERFLOW;
161                exc.name = "cosh";
162                if (_LIB_VERSION == _SVID_)
163                  exc.retval = HUGE;
164                else
165                  exc.retval = HUGE_VAL;
166                if (_LIB_VERSION == _POSIX_)
167                  errno = ERANGE;
168                else if (!matherr(&exc)) {
169                        errno = ERANGE;
170                }
171                break;
172            case 6:
173                /* exp(finite) overflow */
174                exc.type = OVERFLOW;
175                exc.name = "exp";
176                if (_LIB_VERSION == _SVID_)
177                  exc.retval = HUGE;
178                else
179                  exc.retval = HUGE_VAL;
180                if (_LIB_VERSION == _POSIX_)
181                  errno = ERANGE;
182                else if (!matherr(&exc)) {
183                        errno = ERANGE;
184                }
185                break;
186            case 7:
187                /* exp(finite) underflow */
188                exc.type = UNDERFLOW;
189                exc.name = "exp";
190                exc.retval = zero;
191                if (_LIB_VERSION == _POSIX_)
192                  errno = ERANGE;
193                else if (!matherr(&exc)) {
194                        errno = ERANGE;
195                }
196                break;
197            case 8:
198                /* y0(0) = -inf */
199                exc.type = DOMAIN;      /* should be SING for IEEE */
200                exc.name = "y0";
201                if (_LIB_VERSION == _SVID_)
202                  exc.retval = -HUGE;
203                else
204                  exc.retval = -HUGE_VAL;
205                if (_LIB_VERSION == _POSIX_)
206                  errno = EDOM;
207                else if (!matherr(&exc)) {
208                  if (_LIB_VERSION == _SVID_) {
209                        (void) WRITE2("y0: DOMAIN error\n", 17);
210                      }
211                  errno = EDOM;
212                }
213                break;
214            case 9:
215                /* y0(x<0) = NaN */
216                exc.type = DOMAIN;
217                exc.name = "y0";
218                if (_LIB_VERSION == _SVID_)
219                  exc.retval = -HUGE;
220                else
221                  exc.retval = -HUGE_VAL;
222                if (_LIB_VERSION == _POSIX_)
223                  errno = EDOM;
224                else if (!matherr(&exc)) {
225                  if (_LIB_VERSION == _SVID_) {
226                        (void) WRITE2("y0: DOMAIN error\n", 17);
227                      }
228                  errno = EDOM;
229                }
230                break;
231            case 10:
232                /* y1(0) = -inf */
233                exc.type = DOMAIN;      /* should be SING for IEEE */
234                exc.name = "y1";
235                if (_LIB_VERSION == _SVID_)
236                  exc.retval = -HUGE;
237                else
238                  exc.retval = -HUGE_VAL;
239                if (_LIB_VERSION == _POSIX_)
240                  errno = EDOM;
241                else if (!matherr(&exc)) {
242                  if (_LIB_VERSION == _SVID_) {
243                        (void) WRITE2("y1: DOMAIN error\n", 17);
244                      }
245                  errno = EDOM;
246                }
247                break;
248            case 11:
249                /* y1(x<0) = NaN */
250                exc.type = DOMAIN;
251                exc.name = "y1";
252                if (_LIB_VERSION == _SVID_)
253                  exc.retval = -HUGE;
254                else
255                  exc.retval = -HUGE_VAL;
256                if (_LIB_VERSION == _POSIX_)
257                  errno = EDOM;
258                else if (!matherr(&exc)) {
259                  if (_LIB_VERSION == _SVID_) {
260                        (void) WRITE2("y1: DOMAIN error\n", 17);
261                      }
262                  errno = EDOM;
263                }
264                break;
265            case 12:
266                /* yn(n,0) = -inf */
267                exc.type = DOMAIN;      /* should be SING for IEEE */
268                exc.name = "yn";
269                if (_LIB_VERSION == _SVID_)
270                  exc.retval = -HUGE;
271                else
272                  exc.retval = -HUGE_VAL;
273                if (_LIB_VERSION == _POSIX_)
274                  errno = EDOM;
275                else if (!matherr(&exc)) {
276                  if (_LIB_VERSION == _SVID_) {
277                        (void) WRITE2("yn: DOMAIN error\n", 17);
278                      }
279                  errno = EDOM;
280                }
281                break;
282            case 13:
283                /* yn(x<0) = NaN */
284                exc.type = DOMAIN;
285                exc.name = "yn";
286                if (_LIB_VERSION == _SVID_)
287                  exc.retval = -HUGE;
288                else
289                  exc.retval = -HUGE_VAL;
290                if (_LIB_VERSION == _POSIX_)
291                  errno = EDOM;
292                else if (!matherr(&exc)) {
293                  if (_LIB_VERSION == _SVID_) {
294                        (void) WRITE2("yn: DOMAIN error\n", 17);
295                      }
296                  errno = EDOM;
297                }
298                break;
299            case 14:
300                /* lgamma(finite) overflow */
301                exc.type = OVERFLOW;
302                exc.name = "lgamma";
303                if (_LIB_VERSION == _SVID_)
304                  exc.retval = HUGE;
305                else
306                  exc.retval = HUGE_VAL;
307                if (_LIB_VERSION == _POSIX_)
308                        errno = ERANGE;
309                else if (!matherr(&exc)) {
310                        errno = ERANGE;
311                }
312                break;
313            case 15:
314                /* lgamma(-integer) or lgamma(0) */
315                exc.type = SING;
316                exc.name = "lgamma";
317                if (_LIB_VERSION == _SVID_)
318                  exc.retval = HUGE;
319                else
320                  exc.retval = HUGE_VAL;
321                if (_LIB_VERSION == _POSIX_)
322                  errno = EDOM;
323                else if (!matherr(&exc)) {
324                  if (_LIB_VERSION == _SVID_) {
325                        (void) WRITE2("lgamma: SING error\n", 19);
326                      }
327                  errno = EDOM;
328                }
329                break;
330            case 16:
331                /* log(0) */
332                exc.type = SING;
333                exc.name = "log";
334                if (_LIB_VERSION == _SVID_)
335                  exc.retval = -HUGE;
336                else
337                  exc.retval = -HUGE_VAL;
338                if (_LIB_VERSION == _POSIX_)
339                  errno = ERANGE;
340                else if (!matherr(&exc)) {
341                  if (_LIB_VERSION == _SVID_) {
342                        (void) WRITE2("log: SING error\n", 16);
343                      }
344                  errno = EDOM;
345                }
346                break;
347            case 17:
348                /* log(x<0) */
349                exc.type = DOMAIN;
350                exc.name = "log";
351                if (_LIB_VERSION == _SVID_)
352                  exc.retval = -HUGE;
353                else
354                  exc.retval = -HUGE_VAL;
355                if (_LIB_VERSION == _POSIX_)
356                  errno = EDOM;
357                else if (!matherr(&exc)) {
358                  if (_LIB_VERSION == _SVID_) {
359                        (void) WRITE2("log: DOMAIN error\n", 18);
360                      }
361                  errno = EDOM;
362                }
363                break;
364            case 18:
365                /* log10(0) */
366                exc.type = SING;
367                exc.name = "log10";
368                if (_LIB_VERSION == _SVID_)
369                  exc.retval = -HUGE;
370                else
371                  exc.retval = -HUGE_VAL;
372                if (_LIB_VERSION == _POSIX_)
373                  errno = ERANGE;
374                else if (!matherr(&exc)) {
375                  if (_LIB_VERSION == _SVID_) {
376                        (void) WRITE2("log10: SING error\n", 18);
377                      }
378                  errno = EDOM;
379                }
380                break;
381            case 19:
382                /* log10(x<0) */
383                exc.type = DOMAIN;
384                exc.name = "log10";
385                if (_LIB_VERSION == _SVID_)
386                  exc.retval = -HUGE;
387                else
388                  exc.retval = -HUGE_VAL;
389                if (_LIB_VERSION == _POSIX_)
390                  errno = EDOM;
391                else if (!matherr(&exc)) {
392                  if (_LIB_VERSION == _SVID_) {
393                        (void) WRITE2("log10: DOMAIN error\n", 20);
394                      }
395                  errno = EDOM;
396                }
397                break;
398            case 20:
399                /* pow(0.0,0.0) */
400                /* error only if _LIB_VERSION == _SVID_ */
401                exc.type = DOMAIN;
402                exc.name = "pow";
403                exc.retval = zero;
404                if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
405                else if (!matherr(&exc)) {
406                        (void) WRITE2("pow(0,0): DOMAIN error\n", 23);
407                        errno = EDOM;
408                }
409                break;
410            case 21:
411                /* pow(x,y) overflow */
412                exc.type = OVERFLOW;
413                exc.name = "pow";
414                if (_LIB_VERSION == _SVID_) {
415                  exc.retval = HUGE;
416                  y *= 0.5;
417                  if(x<zero&&rint(y)!=y) exc.retval = -HUGE;
418                } else {
419                  exc.retval = HUGE_VAL;
420                  y *= 0.5;
421                  if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL;
422                }
423                if (_LIB_VERSION == _POSIX_)
424                  errno = ERANGE;
425                else if (!matherr(&exc)) {
426                        errno = ERANGE;
427                }
428                break;
429            case 22:
430                /* pow(x,y) underflow */
431                exc.type = UNDERFLOW;
432                exc.name = "pow";
433                exc.retval =  zero;
434                if (_LIB_VERSION == _POSIX_)
435                  errno = ERANGE;
436                else if (!matherr(&exc)) {
437                        errno = ERANGE;
438                }
439                break;
440            case 23:
441                /* 0**neg */
442                exc.type = DOMAIN;
443                exc.name = "pow";
444                if (_LIB_VERSION == _SVID_) 
445                  exc.retval = zero;
446                else
447                  exc.retval = -HUGE_VAL;
448                if (_LIB_VERSION == _POSIX_)
449                  errno = EDOM;
450                else if (!matherr(&exc)) {
451                  if (_LIB_VERSION == _SVID_) {
452                        (void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
453                      }
454                  errno = EDOM;
455                }
456                break;
457            case 24:
458                /* neg**non-integral */
459                exc.type = DOMAIN;
460                exc.name = "pow";
461                if (_LIB_VERSION == _SVID_) 
462                    exc.retval = zero;
463                else 
464                    exc.retval = zero/zero;     /* X/Open allow NaN */
465                if (_LIB_VERSION == _POSIX_) 
466                   errno = EDOM;
467                else if (!matherr(&exc)) {
468                  if (_LIB_VERSION == _SVID_) {
469                        (void) WRITE2("neg**non-integral: DOMAIN error\n", 32);
470                      }
471                  errno = EDOM;
472                }
473                break;
474            case 25:
475                /* sinh(finite) overflow */
476                exc.type = OVERFLOW;
477                exc.name = "sinh";
478                if (_LIB_VERSION == _SVID_)
479                  exc.retval = ( (x>zero) ? HUGE : -HUGE);
480                else
481                  exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL);
482                if (_LIB_VERSION == _POSIX_)
483                  errno = ERANGE;
484                else if (!matherr(&exc)) {
485                        errno = ERANGE;
486                }
487                break;
488            case 26:
489                /* sqrt(x<0) */
490                exc.type = DOMAIN;
491                exc.name = "sqrt";
492                if (_LIB_VERSION == _SVID_)
493                  exc.retval = zero;
494                else
495                  exc.retval = zero/zero;
496                if (_LIB_VERSION == _POSIX_)
497                  errno = EDOM;
498                else if (!matherr(&exc)) {
499                  if (_LIB_VERSION == _SVID_) {
500                        (void) WRITE2("sqrt: DOMAIN error\n", 19);
501                      }
502                  errno = EDOM;
503                }
504                break;
505            case 27:
506                /* fmod(x,0) */
507                exc.type = DOMAIN;
508                exc.name = "fmod";
509                if (_LIB_VERSION == _SVID_)
510                    exc.retval = x;
511                else
512                    exc.retval = zero/zero;
513                if (_LIB_VERSION == _POSIX_)
514                  errno = EDOM;
515                else if (!matherr(&exc)) {
516                  if (_LIB_VERSION == _SVID_) {
517                    (void) WRITE2("fmod:  DOMAIN error\n", 20);
518                  }
519                  errno = EDOM;
520                }
521                break;
522            case 28:
523                /* remainder(x,0) */
524                exc.type = DOMAIN;
525                exc.name = "remainder";
526                exc.retval = zero/zero;
527                if (_LIB_VERSION == _POSIX_)
528                  errno = EDOM;
529                else if (!matherr(&exc)) {
530                  if (_LIB_VERSION == _SVID_) {
531                    (void) WRITE2("remainder: DOMAIN error\n", 24);
532                  }
533                  errno = EDOM;
534                }
535                break;
536            case 29:
537                /* acosh(x<1) */
538                exc.type = DOMAIN;
539                exc.name = "acosh";
540                exc.retval = zero/zero;
541                if (_LIB_VERSION == _POSIX_)
542                  errno = EDOM;
543                else if (!matherr(&exc)) {
544                  if (_LIB_VERSION == _SVID_) {
545                    (void) WRITE2("acosh: DOMAIN error\n", 20);
546                  }
547                  errno = EDOM;
548                }
549                break;
550            case 30:
551                /* atanh(|x|>1) */
552                exc.type = DOMAIN;
553                exc.name = "atanh";
554                exc.retval = zero/zero;
555                if (_LIB_VERSION == _POSIX_)
556                  errno = EDOM;
557                else if (!matherr(&exc)) {
558                  if (_LIB_VERSION == _SVID_) {
559                    (void) WRITE2("atanh: DOMAIN error\n", 20);
560                  }
561                  errno = EDOM;
562                }
563                break;
564            case 31:
565                /* atanh(|x|=1) */
566                exc.type = SING;
567                exc.name = "atanh";
568                exc.retval = x/zero;    /* sign(x)*inf */
569                if (_LIB_VERSION == _POSIX_)
570                  errno = EDOM;
571                else if (!matherr(&exc)) {
572                  if (_LIB_VERSION == _SVID_) {
573                    (void) WRITE2("atanh: SING error\n", 18);
574                  }
575                  errno = EDOM;
576                }
577                break;
578            case 32:
579                /* scalb overflow; SVID also returns +-HUGE_VAL */
580                exc.type = OVERFLOW;
581                exc.name = "scalb";
582                exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
583                if (_LIB_VERSION == _POSIX_)
584                  errno = ERANGE;
585                else if (!matherr(&exc)) {
586                        errno = ERANGE;
587                }
588                break;
589            case 33:
590                /* scalb underflow */
591                exc.type = UNDERFLOW;
592                exc.name = "scalb";
593                exc.retval = copysign(zero,x);
594                if (_LIB_VERSION == _POSIX_)
595                  errno = ERANGE;
596                else if (!matherr(&exc)) {
597                        errno = ERANGE;
598                }
599                break;
600            case 34:
601                /* j0(|x|>X_TLOSS) */
602                exc.type = TLOSS;
603                exc.name = "j0";
604                exc.retval = zero;
605                if (_LIB_VERSION == _POSIX_)
606                        errno = ERANGE;
607                else if (!matherr(&exc)) {
608                        if (_LIB_VERSION == _SVID_) {
609                                (void) WRITE2(exc.name, 2);
610                                (void) WRITE2(": TLOSS error\n", 14);
611                        }
612                        errno = ERANGE;
613                }       
614                break;
615            case 35:
616                /* y0(x>X_TLOSS) */
617                exc.type = TLOSS;
618                exc.name = "y0";
619                exc.retval = zero;
620                if (_LIB_VERSION == _POSIX_)
621                        errno = ERANGE;
622                else if (!matherr(&exc)) {
623                        if (_LIB_VERSION == _SVID_) {
624                                (void) WRITE2(exc.name, 2);
625                                (void) WRITE2(": TLOSS error\n", 14);
626                        }
627                        errno = ERANGE;
628                }       
629                break;
630            case 36:
631                /* j1(|x|>X_TLOSS) */
632                exc.type = TLOSS;
633                exc.name = "j1";
634                exc.retval = zero;
635                if (_LIB_VERSION == _POSIX_)
636                        errno = ERANGE;
637                else if (!matherr(&exc)) {
638                        if (_LIB_VERSION == _SVID_) {
639                                (void) WRITE2(exc.name, 2);
640                                (void) WRITE2(": TLOSS error\n", 14);
641                        }
642                        errno = ERANGE;
643                }       
644                break;
645            case 37:
646                /* y1(x>X_TLOSS) */
647                exc.type = TLOSS;
648                exc.name = "y1";
649                exc.retval = zero;
650                if (_LIB_VERSION == _POSIX_)
651                        errno = ERANGE;
652                else if (!matherr(&exc)) {
653                        if (_LIB_VERSION == _SVID_) {
654                                (void) WRITE2(exc.name, 2);
655                                (void) WRITE2(": TLOSS error\n", 14);
656                        }
657                        errno = ERANGE;
658                }       
659                break;
660            case 38:
661                /* jn(|x|>X_TLOSS) */
662                exc.type = TLOSS;
663                exc.name = "jn";
664                exc.retval = zero;
665                if (_LIB_VERSION == _POSIX_)
666                        errno = ERANGE;
667                else if (!matherr(&exc)) {
668                        if (_LIB_VERSION == _SVID_) {
669                                (void) WRITE2(exc.name, 2);
670                                (void) WRITE2(": TLOSS error\n", 14);
671                        }
672                        errno = ERANGE;
673                }       
674                break;
675            case 39:
676                /* yn(x>X_TLOSS) */
677                exc.type = TLOSS;
678                exc.name = "yn";
679                exc.retval = zero;
680                if (_LIB_VERSION == _POSIX_)
681                        errno = ERANGE;
682                else if (!matherr(&exc)) {
683                        if (_LIB_VERSION == _SVID_) {
684                                (void) WRITE2(exc.name, 2);
685                                (void) WRITE2(": TLOSS error\n", 14);
686                        }
687                        errno = ERANGE;
688                }       
689                break;
690            case 40:
691                /* gamma(finite) overflow */
692                exc.type = OVERFLOW;
693                exc.name = "gamma";
694                if (_LIB_VERSION == _SVID_)
695                  exc.retval = HUGE;
696                else
697                  exc.retval = HUGE_VAL;
698                if (_LIB_VERSION == _POSIX_)
699                  errno = ERANGE;
700                else if (!matherr(&exc)) {
701                  errno = ERANGE;
702                }
703                break;
704            case 41:
705                /* gamma(-integer) or gamma(0) */
706                exc.type = SING;
707                exc.name = "gamma";
708                if (_LIB_VERSION == _SVID_)
709                  exc.retval = HUGE;
710                else
711                  exc.retval = HUGE_VAL;
712                if (_LIB_VERSION == _POSIX_)
713                  errno = EDOM;
714                else if (!matherr(&exc)) {
715                  if (_LIB_VERSION == _SVID_) {
716                        (void) WRITE2("gamma: SING error\n", 18);
717                      }
718                  errno = EDOM;
719                }
720                break;
721            case 42:
722                /* pow(NaN,0.0) */
723                /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
724                exc.type = DOMAIN;
725                exc.name = "pow";
726                exc.retval = x;
727                if (_LIB_VERSION == _IEEE_ ||
728                    _LIB_VERSION == _POSIX_) exc.retval = 1.0;
729                else if (!matherr(&exc)) {
730                        errno = EDOM;
731                }
732                break;
733        }
734        return exc.retval; 
735}
Note: See TracBrowser for help on using the repository browser.