forked from dontcallmedom/spiff
-
Notifications
You must be signed in to change notification settings - Fork 2
/
floatrep.h
66 lines (49 loc) · 1.34 KB
/
floatrep.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Copyright (c) 1988 Bellcore
** All Rights Reserved
** Permission is granted to copy or use this program, EXCEPT that it
** may not be sold for profit, the copyright notice must be reproduced
** on copies, and credit should be given to Bellcore where it is due.
** BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
*/
/*
** header file that defines canonical floating point structure
** and routines
*/
#ifndef R_INCLUDED
/*
** when evaluated to a string, the fractional part will
** not exceed this length
*/
#define R_MANMAX 330
#define R_POSITIVE 0
#define R_NEGATIVE 1
struct R_flstr {
int exponent;
int man_sign;
char *mantissa;
};
typedef struct R_flstr *R_float;
#define R_getfrac(x) (x->mantissa)
extern R_float R_makefloat();
extern int R_getexp();
#define R_getsign(x) (x->man_sign)
/*
** takes a string
*/
#define R_setfrac(x,y) ((void)strcpy(x->mantissa,y))
/*
** takes an int
*/
#define R_setexp(x,y) (x->exponent = y)
/*
** takes a sign
*/
#define R_setsign(x,y) (x->man_sign = y)
/*
#define R_incexp(x) ((x->exponent)++)
#define R_decexp(x) ((x->exponent)--)
*/
#define R_setzero(x) R_setfrac(x,"0");R_setexp(x,0);R_setsign(x,R_POSITIVE)
#define R_zerofloat(x) ((0 == x->exponent) && (!strcmp(x->mantissa,"0")))
#define R_INCLUDED
#endif