Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/sfio/tlongdouble.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1999-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "sftest.h"
21
22
#if _typ_long_double
23
#include <float.h>
24
#endif
25
26
tmain()
27
{
28
#if _typ_long_double
29
long double ldval, ldmax;
30
char *s, *str;
31
32
if(sfsscanf("Inf","%Le",&ldmax) != 1)
33
terror("sfsscanf Inf failed");
34
if(!(s = sfprints("%Le",ldmax)) )
35
terror("sfprints failed1");
36
if(!(str = malloc(strlen(s)+1)) )
37
terror("Malloc failed");
38
strcpy(str,s);
39
40
if(sfsscanf(str,"%Le",&ldval) != 1)
41
terror("sfsscanf failed");
42
if(!(s = sfprints("%Le",ldval)) )
43
terror("sfprints failed2");
44
45
if(strcmp(s,str) != 0)
46
terror("Bad conversion, expecting %s and getting %s",str,s);
47
#endif
48
49
texit(0);
50
}
51
52