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
, const char *fmt
, double val
)
21 return snprintf(NULL
, 0, fmt
, val
);
22 return sprintf(buf
, fmt
, val
);
25 double double_signum(double val
)
32 float float_signum(float val
)
39 int double_classify(double val
)
41 switch (fpclassify(val
)) {
57 int float_classify(float val
)
59 switch (fpclassify(val
)) {
75 int double_compare(double a
, double b
)
83 if (isunordered(a
, b
))
88 int float_compare(float a
, float b
)
96 if (isunordered(a
, b
))