1f08c3bdfSopenharmony_ci/*
2f08c3bdfSopenharmony_ci *
3f08c3bdfSopenharmony_ci *   Copyright (c) International Business Machines  Corp., 2002
4f08c3bdfSopenharmony_ci *
5f08c3bdfSopenharmony_ci *   This program is free software;  you can redistribute it and/or modify
6f08c3bdfSopenharmony_ci *   it under the terms of the GNU General Public License as published by
7f08c3bdfSopenharmony_ci *   the Free Software Foundation; either version 2 of the License, or
8f08c3bdfSopenharmony_ci *   (at your option) any later version.
9f08c3bdfSopenharmony_ci *
10f08c3bdfSopenharmony_ci *   This program is distributed in the hope that it will be useful,
11f08c3bdfSopenharmony_ci *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12f08c3bdfSopenharmony_ci *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13f08c3bdfSopenharmony_ci *   the GNU General Public License for more details.
14f08c3bdfSopenharmony_ci *
15f08c3bdfSopenharmony_ci *   You should have received a copy of the GNU General Public License
16f08c3bdfSopenharmony_ci *   along with this program;  if not, write to the Free Software
17f08c3bdfSopenharmony_ci *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18f08c3bdfSopenharmony_ci */
19f08c3bdfSopenharmony_ci
20f08c3bdfSopenharmony_ci/* 01/02/2003	Port to LTP	avenkat@us.ibm.com */
21f08c3bdfSopenharmony_ci/* 06/30/2001	Port to Linux	nsharoff@us.ibm.com */
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci/*
24f08c3bdfSopenharmony_ci * NAME
25f08c3bdfSopenharmony_ci *      scalb
26f08c3bdfSopenharmony_ci *
27f08c3bdfSopenharmony_ci * CALLS
28f08c3bdfSopenharmony_ci *      nextafter(3C)
29f08c3bdfSopenharmony_ci *
30f08c3bdfSopenharmony_ci * ALGORITHM
31f08c3bdfSopenharmony_ci *	Check results from the above functions against expected values.
32f08c3bdfSopenharmony_ci *
33f08c3bdfSopenharmony_ci * RESTRICTIONS
34f08c3bdfSopenharmony_ci * 	Checks for basic functionality, nothing fancy
35f08c3bdfSopenharmony_ci */
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ci#include <errno.h>
38f08c3bdfSopenharmony_ci#include <math.h>
39f08c3bdfSopenharmony_ci#include <stdio.h>
40f08c3bdfSopenharmony_ci#include <stdlib.h>
41f08c3bdfSopenharmony_ci#include "test.h"
42f08c3bdfSopenharmony_ci
43f08c3bdfSopenharmony_ci#define	FAILED 0
44f08c3bdfSopenharmony_ci#define	PASSED 1
45f08c3bdfSopenharmony_ci
46f08c3bdfSopenharmony_cichar *TCID = "nextafter01";
47f08c3bdfSopenharmony_ci
48f08c3bdfSopenharmony_ciint local_flag = PASSED;
49f08c3bdfSopenharmony_ciint block_number;
50f08c3bdfSopenharmony_ciFILE *temp;
51f08c3bdfSopenharmony_ciint TST_TOTAL = 1;
52f08c3bdfSopenharmony_ci
53f08c3bdfSopenharmony_civoid setup();
54f08c3bdfSopenharmony_civoid blenter();
55f08c3bdfSopenharmony_civoid blexit();
56f08c3bdfSopenharmony_ci
57f08c3bdfSopenharmony_ci/*--------------------------------------------------------------*/
58f08c3bdfSopenharmony_ciint main()
59f08c3bdfSopenharmony_ci{
60f08c3bdfSopenharmony_ci	double answer;
61f08c3bdfSopenharmony_ci	double check;		/* tmp variable */
62f08c3bdfSopenharmony_ci
63f08c3bdfSopenharmony_ci	setup();		/* temp file is now open */
64f08c3bdfSopenharmony_ci/*--------------------------------------------------------------*/
65f08c3bdfSopenharmony_ci	blenter();
66f08c3bdfSopenharmony_ci
67f08c3bdfSopenharmony_ci	answer = nextafter(1.0, 1.1);
68f08c3bdfSopenharmony_ci	check = (answer + 1.0) / 2;
69f08c3bdfSopenharmony_ci	if ((check != answer) && ((float)check != 1.0)) {
70f08c3bdfSopenharmony_ci		fprintf(temp, "nextafter returned %e, expected answer or 1.0\n",
71f08c3bdfSopenharmony_ci			answer);
72f08c3bdfSopenharmony_ci		local_flag = FAILED;
73f08c3bdfSopenharmony_ci	}
74f08c3bdfSopenharmony_ci
75f08c3bdfSopenharmony_ci	blexit();
76f08c3bdfSopenharmony_ci/*--------------------------------------------------------------*/
77f08c3bdfSopenharmony_ci	blenter();
78f08c3bdfSopenharmony_ci
79f08c3bdfSopenharmony_ci	answer = nextafter(1.0, 0.9);
80f08c3bdfSopenharmony_ci	if ((check != answer) && (check != 1.0)) {
81f08c3bdfSopenharmony_ci		fprintf(temp, "nextafter returned %e, expected answer or 1.0\n",
82f08c3bdfSopenharmony_ci			answer);
83f08c3bdfSopenharmony_ci		local_flag = FAILED;
84f08c3bdfSopenharmony_ci	}
85f08c3bdfSopenharmony_ci
86f08c3bdfSopenharmony_ci	blexit();
87f08c3bdfSopenharmony_ci/*--------------------------------------------------------------*/
88f08c3bdfSopenharmony_ci	blenter();
89f08c3bdfSopenharmony_ci
90f08c3bdfSopenharmony_ci	answer = nextafter(1.0, 1.0);
91f08c3bdfSopenharmony_ci	if (answer != 1.0) {
92f08c3bdfSopenharmony_ci		fprintf(temp, "nextafter 3 returned %e, expected 1.0\n",
93f08c3bdfSopenharmony_ci			answer);
94f08c3bdfSopenharmony_ci		local_flag = FAILED;
95f08c3bdfSopenharmony_ci	}
96f08c3bdfSopenharmony_ci
97f08c3bdfSopenharmony_ci	blexit();
98f08c3bdfSopenharmony_ci/*--------------------------------------------------------------*/
99f08c3bdfSopenharmony_ci
100f08c3bdfSopenharmony_ci	tst_exit();
101f08c3bdfSopenharmony_ci}
102f08c3bdfSopenharmony_ci
103f08c3bdfSopenharmony_ci/*--------------------------------------------------------------*/
104f08c3bdfSopenharmony_ci
105f08c3bdfSopenharmony_ci/*****	*****	LTP Port	*****/
106f08c3bdfSopenharmony_ci
107f08c3bdfSopenharmony_ci/* FUNCTIONS */
108f08c3bdfSopenharmony_ci
109f08c3bdfSopenharmony_civoid setup()
110f08c3bdfSopenharmony_ci{
111f08c3bdfSopenharmony_ci	temp = stderr;
112f08c3bdfSopenharmony_ci}
113f08c3bdfSopenharmony_ci
114f08c3bdfSopenharmony_civoid blenter()
115f08c3bdfSopenharmony_ci{
116f08c3bdfSopenharmony_ci	local_flag = PASSED;
117f08c3bdfSopenharmony_ci}
118f08c3bdfSopenharmony_ci
119f08c3bdfSopenharmony_civoid blexit()
120f08c3bdfSopenharmony_ci{
121f08c3bdfSopenharmony_ci	if (local_flag == PASSED)
122f08c3bdfSopenharmony_ci		tst_resm(TPASS, "Test passed");
123f08c3bdfSopenharmony_ci	else
124f08c3bdfSopenharmony_ci		tst_resm(TFAIL, "Test failed");
125f08c3bdfSopenharmony_ci}
126f08c3bdfSopenharmony_ci
127f08c3bdfSopenharmony_ci/*****	*****		*****/
128