2 * Floating point functions that are difficult or impossible to implement
5 * Copyright (C) 2009 Nick Bowler.
7 * License BSD2: 2-clause BSD license. See LICENSE for full terms.
8 * This is free software: you are free to change and redistribute it.
9 * There is NO WARRANTY, to the extent permitted by law.
18 int double_format(char *buf
, char spec
, int precision
, double val
)
24 return snprintf(NULL
, 0, fmt
, precision
, val
);
25 return sprintf(buf
, fmt
, precision
, val
);
28 double double_signum(double val
)
35 float float_signum(float val
)
42 int double_classify(double val
)
44 switch (fpclassify(val
)) {
60 int float_classify(float val
)
62 switch (fpclassify(val
)) {
78 int double_compare(double a
, double b
)
86 if (isunordered(a
, b
))
91 int float_compare(float a
, float b
)
99 if (isunordered(a
, b
))