Debian Codegraph @

src/c/numbers/zerop.d

raw
1 /* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /* vim: set filetype=c tabstop=2 shiftwidth=2 expandtab: */
3
4 /*
5 * zerop.d - implementation of CL:ZEROP
6 *
7 * Copyright (c) 1984 Taiichi Yuasa and Masami Hagiya
8 * Copyright (c) 1990 Giuseppe Attardi
9 * Copyright (c) 2001 Juan Jose Garcia Ripoll
10 *
11 * See file 'LICENSE' for the copyright details.
12 *
13 */
14
15
16 #include <ecl/ecl.h>
17 #include <ecl/impl/math_dispatch.h>
18
19 cl_object
20 cl_zerop(cl_object x)
21 { /* INV: ecl_zerop() checks type */
22 @(return (ecl_zerop(x) ? ECL_T : ECL_NIL));
23 }
24
25 static int
26 ecl_zerop_fixnum(cl_object x)
27 {
28 return x == ecl_make_fixnum(0);
29 }
30
31 static int
32 ecl_zerop_ratio(cl_object x)
33 {
34 return 0;
35 }
36
37 static int
38 ecl_zerop_single_float(cl_object x)
39 {
40 return ecl_single_float(x) == 0;
41 }
42
43 static int
44 ecl_zerop_double_float(cl_object x)
45 {
46 return ecl_double_float(x) == 0;
47 }
48
49 static int ecl_zerop_long_float(cl_object x)
50 {
51 return ecl_long_float(x) == 0;
52 }
53
54 static int
55 ecl_zerop_complex(cl_object x)
56 {
57 return ecl_zerop(x->gencomplex.real) && ecl_zerop(x->gencomplex.imag);
58 }
59
60 #ifdef ECL_COMPLEX_FLOAT
61 static int
62 ecl_zerop_csfloat(cl_object x)
63 {
64 return ecl_csfloat(x) == 0;
65 }
66
67 static int
68 ecl_zerop_cdfloat(cl_object x)
69 {
70 return ecl_cdfloat(x) == 0;
71 }
72
73 static int
74 ecl_zerop_clfloat(cl_object x)
75 {
76 return ecl_clfloat(x) == 0;
77 }
78 #endif
79
80
81 MATH_DEF_DISPATCH1_BOOL(zerop, @[zerop], @[number],
82 ecl_zerop_fixnum, ecl_zerop_ratio, ecl_zerop_ratio,
83 ecl_zerop_single_float, ecl_zerop_double_float,
84 ecl_zerop_long_float,
85 ecl_zerop_complex,
86 ecl_zerop_csfloat, ecl_zerop_cdfloat, ecl_zerop_clfloat)