annotate test/testmmousetablet.c @ 2752:edd2839b36f7

http://sources.redhat.com/ml/newlib/2002/msg00230.html Stephen L Moshier wrote: > > pow(x,y) returns 0 when x is very close to -1.0 and y is very large. > The following test program prints > > pow(1.0000000000000002e+00 4.5035996273704970e+15) = 2.7182818284590455e+00 > pow(-1.0000000000000002e+00 4.5035996273704970e+15) =0.0000000000000000e+00 > pow(9.9999999999999978e-01 4.5035996273704970e+15) = 3.6787944117144222e-01 > pow(-9.9999999999999978e-01 4.5035996273704970e+15) = 0.0000000000000000e+00 > > which is incorrect for the negative arguments raised to an odd integer > power. > > ----- > double pow (double, double); > > int > main () > { > double x, y, z; > > x = 1.0 + pow (2.0, -52.0); > y = 1.0 + pow (2.0, 52.0); > z = pow (x, y); > printf ("pow(%.16e %.16e) = %.16e\n", x, y, z); > x = -x; > z = pow (x, y); > printf ("pow(%.16e %.16e) = %.16e\n", x, y, z); > x = 1.0 - pow (2.0, -52.0); > z = pow (x, y); > printf ("pow(%.16e %.16e) = %.16e\n", x, y, z); > x = -x; > z = pow (x, y); > printf ("pow(%.16e %.16e) = %.16e\n", x, y, z); > } > ----- > > Here is a patch for newlib/libm/math/epow.c: Patch checked in and duplicated for ef_pow.c. Thanks. -- Jeff J.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 15 Sep 2008 04:31:30 +0000
parents ae653575d4af
children 975fd903466b
rev   line source
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
2 #include "SDL.h"
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
3
2736
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
4 SDL_Surface *screen;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
5 int quit = 0;
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
6
2736
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
7 int
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
8 main()
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
9 {
2736
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
10 SDL_Event event;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
11 int mice;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
12 int i;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
13 printf("Initing...\n");
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
14 if (SDL_Init(0) != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
15 return 1;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
16 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
17 if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
18 return 1;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
19 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
20 screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
21 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
22 mice = SDL_GetNumMice();
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
23 printf("%d pointing devices found\n", mice);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
24 for (i = 0; i < mice; ++i) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
25 printf("device index: %d name:%s\n", i, SDL_GetMouseName(i));
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
26 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
27 while (quit != 1) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
28 if (SDL_PollEvent(&event) == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
29 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
30 switch (event.type) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
31 case SDL_MOUSEMOTION:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
32 printf
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
33 ("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
34 pressure_max: %d pressure_min: %d current cursor:%d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
35 event.motion.which, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
36 event.motion.pressure, event.motion.pressure_max, event.motion.pressure_min,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
37 event.motion.cursor);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
38 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
39 case SDL_PROXIMITYIN:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
40 printf("proximity in id: %d x: %d y: %d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
41 (int) event.proximity.which, event.proximity.x,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
42 event.proximity.y);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
43 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
44 case SDL_PROXIMITYOUT:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
45 printf("proximity out id: %d x: %d y: %d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
46 (int) event.proximity.which, event.proximity.x,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
47 event.proximity.y);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
48 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
49 case SDL_MOUSEBUTTONDOWN:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
50 printf("mouse button down id: %d button:%d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
51 event.button.which, event.button.button);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
52 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
53 case SDL_MOUSEBUTTONUP:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
54 printf("mouse button up id: %d button: %d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
55 event.button.which, event.button.button);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
56 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
57 case SDL_QUIT:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
58 printf("Quitting\n");
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
59 SDL_QuitSubSystem(SDL_INIT_VIDEO);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
60 SDL_Quit();
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
61 quit = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
62 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
63 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
64 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
65 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
66 return 0;
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
67 }