~ubuntu-branches/ubuntu/wily/avr-libc/wily-proposed

« back to all changes in this revision

Viewing changes to tests/simulate/math/ldexp-nan.c

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2009-10-31 11:52:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091031115210-crjd42sn6ezrj52c
Tags: 1:1.6.7-1
* New upstream relese (closes: #544030)
* Added lintian overrides (closes: #553265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Test of ldexp function.  NaNs.
2
 
   $Id: ldexp-nan.c,v 1.1 2007/02/05 21:35:58 dmix Exp $
3
 
 */
4
 
#include <math.h>
5
 
#include <stdio.h>
6
 
#include <stdlib.h>
7
 
#include "progmem.h"
8
 
 
9
 
union lofl_u {
10
 
    long lo;
11
 
    float fl;
12
 
};
13
 
 
14
 
volatile union lofl_u v = { .lo = 1 };
15
 
 
16
 
PROGMEM const struct {          /* Table of test cases. */
17
 
    union lofl_u x;
18
 
    int y;
19
 
} t[] = {
20
 
 
21
 
    { { 0x7f800001 }, 1 },
22
 
    { { 0x7f800100 }, 1 },
23
 
    { { 0x7f810000 }, 1 },
24
 
    { { 0x7fffffff }, 1 },
25
 
    { { 0xff800001 }, 1 },
26
 
    { { 0xff800100 }, 1 },
27
 
    { { 0xff810000 }, 1 },
28
 
    { { 0xffffffff }, 1 },
29
 
    
30
 
    { { 0x7fc00000 }, 0 },
31
 
    { { 0xffc00000 }, 0 },
32
 
 
33
 
    { { 0x7fc00000 },  32767 },
34
 
    { { 0x7fc00000 }, -32768 },
35
 
};
36
 
 
37
 
void x_exit (int index)
38
 
{
39
 
#ifndef __AVR__
40
 
    fprintf (stderr, "t[%d]: %e (%#lx)\n", index - 1, v.fl, v.lo);
41
 
#endif
42
 
    exit (index ? index : -1);
43
 
}
44
 
 
45
 
int main ()
46
 
{
47
 
    union lofl_u x;
48
 
    int y;
49
 
    int i;
50
 
 
51
 
    for (i = 0; i < (int) (sizeof(t) / sizeof(t[0])); i++) {
52
 
        x.lo = pgm_read_dword (& t[i].x);
53
 
        y    = pgm_read_word  (& t[i].y);
54
 
        v.fl = ldexp (x.fl, y);
55
 
        if (!isnan(v.fl))
56
 
            x_exit (i+1);
57
 
    }
58
 
    return 0;
59
 
}