P99
p99_double.h
Go to the documentation of this file.
1 /* This may look like nonsense, but it really is -*- mode: C; coding: utf-8 -*- */
2 /* */
3 /* Except for parts copied from previous work and as explicitly stated below, */
4 /* the authors and copyright holders for this work are as follows: */
5 /* (C) copyright 2010-2011 Jens Gustedt, INRIA, France */
6 /* (C) copyright 2012 William Morris */
7 /* */
8 /* This file is free software; it is part of the P99 project. */
9 /* */
10 /* Licensed under the Apache License, Version 2.0 (the "License"); */
11 /* you may not use this file except in compliance with the License. */
12 /* You may obtain a copy of the License at */
13 /* */
14 /* http://www.apache.org/licenses/LICENSE-2.0 */
15 /* */
16 /* Unless required by applicable law or agreed to in writing, software */
17 /* distributed under the License is distributed on an "AS IS" BASIS, */
18 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
19 /* See the License for the specific language governing permissions and */
20 /* limitations under the License. */
21 /* */
22 #ifndef P99_DOUBLE_H_
23 # define P99_DOUBLE_H_
24 
25 #include "p99_if.h"
26 
42 #define P00_DEC_DOUBLE(SIGN, INT, FRAC, ESIGN, EXP, ...) \
43  P99_IF_EMPTY(SIGN)(+)(SIGN)P00_SKIP_ P99_PASTE( \
44  P99_IF_EMPTY(INT)(0)(INT), \
45  ., \
46  P99_IF_EMPTY(FRAC)(0)(FRAC), \
47  E, \
48  P99_IF_EMPTY(ESIGN)(+)(ESIGN), \
49  P99_IF_EMPTY(EXP)(0)(EXP), \
50  __VA_ARGS__)
51 
52 #ifdef P00_DOXYGEN
53 
69 #define P99_DEC_DOUBLE(SIGN, INT, FRAC, ESIGN, EXP)
70 #else
71 P00_DOCUMENT_NUMBER_ARGUMENT(P99_DEC_DOUBLE, 1)
72 P00_DOCUMENT_NUMBER_ARGUMENT(P99_DEC_DOUBLE, 2)
73 P00_DOCUMENT_NUMBER_ARGUMENT(P99_DEC_DOUBLE, 4)
74 #define P99_DEC_DOUBLE(...) \
75  P99_IF_GE(P99_NARG(__VA_ARGS__), 6) \
76  (P00_DEC_DOUBLE(__VA_ARGS__)) \
77  (P00_DEC_DOUBLE(__VA_ARGS__,,,,,))
78 #endif
79 
80 
81 #define P00_HEX_DOUBLE(SIGN, HEXINT, HEXFRAC, ESIGN, BINEXP, ...) \
82  P99_IF_EMPTY(SIGN)(+)(SIGN)P00_SKIP_ P99_PASTE( \
83  0x, \
84  P99_IF_EMPTY(HEXINT)(0)(HEXINT), \
85  ., \
86  P99_IF_EMPTY(HEXFRAC)(0)(HEXFRAC), \
87  P, \
88  P99_IF_EMPTY(ESIGN)(+)(ESIGN), \
89  P99_IF_EMPTY(BINEXP)(0)(BINEXP), \
90  __VA_ARGS__)
91 
92 #ifdef P00_DOXYGEN
93 
98 #define P99_HEX_DOUBLE(SIGN, HEXINT, HEXFRAC, ESIGN, BINEXP)
99 #else
100 P00_DOCUMENT_NUMBER_ARGUMENT(P99_HEX_DOUBLE, 1)
101 P00_DOCUMENT_NUMBER_ARGUMENT(P99_HEX_DOUBLE, 2)
102 P00_DOCUMENT_NUMBER_ARGUMENT(P99_HEX_DOUBLE, 4)
103 #define P99_HEX_DOUBLE(...) \
104  P99_IF_GE(P99_NARG(__VA_ARGS__), 6) \
105  (P00_HEX_DOUBLE(__VA_ARGS__)) \
106  (P00_HEX_DOUBLE(__VA_ARGS__,,,,,))
107 #endif
108 
114 #endif /* !P99_DOUBLE_H_ */
P99_DEC_DOUBLE
#define P99_DEC_DOUBLE(SIGN, INT, FRAC, ESIGN, EXP)
construct a double constant in decimal representation.
Definition: p99_double.h:69
p99_if.h
preprocessor conditionals to use inside macros
P99_HEX_DOUBLE
#define P99_HEX_DOUBLE(SIGN, HEXINT, HEXFRAC, ESIGN, BINEXP)
construct a double constant in hexadecimal representation.
Definition: p99_double.h:98