1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <stdio.h>
#include <math.h>
int main() {
#define TEST(x, y) printf("%.2f, %.2f ==> %.2f\n", x, y, copysign(x, y));
TEST(5.0f, 5.0f);
TEST(5.0f, -5.0f);
TEST(-5.0f, 5.0f);
TEST(-5.0f, -5.0f);
TEST(5.0f, 4.0f);
TEST(5.0f, -4.0f);
TEST(-5.0f, 4.0f);
TEST(-5.0f, -4.0f);
TEST(0.0f, 5.0f);
TEST(0.0f, -5.0f);
TEST(-0.0f, 5.0f);
TEST(-0.0f, -5.0f);
TEST(5.0f, 0.0f);
TEST(5.0f, -0.0f);
TEST(-5.0f, 0.0f);
TEST(-5.0f, -0.0f);
TEST(0.0f, 0.0f);
TEST(0.0f, -0.0f);
TEST(-0.0f, 0.0f);
TEST(-0.0f, -0.0f);
return 0;
}
|