OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libm/] [k_standard.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.