aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/math.c
Commit message (Collapse)AuthorAge
* refactor: format all C files under nvim/ #15977dundargoc2021-10-12
| | | | | | | | * refactor: format all C files under nvim * refactor: disable formatting for Vim-owned files: * src/nvim/indent_c.c * src/nvim/regexp.c * src/nvim/regexp_nfa.c * src/nvim/testdir/samples/memfile_test.c
* refactor: format with uncrustify #15741dundargoc2021-09-22
|
* build: fix fpclassify -Wfloat-conversion warning #15570Ben Noordhuis2021-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Work around a glibc bug where it truncates the argument to fpclassify() from double to float by implementing fpclassify() ourselves. Correctness test (Note that the FP_SUBNORMAL test depends on an atof() that knows how to parse subnormals. Glibc does, not sure about other libcs.): #include <math.h> #include <stdint.h> #include <string.h> int xfpclassify(double d) { uint64_t m; int e; memcpy(&m, &d, sizeof(m)); e = 0x7ff & (m >> 52); m = 0xfffffffffffffULL & m; switch (e) { default: return FP_NORMAL; case 0x000: return m ? FP_SUBNORMAL : FP_ZERO; case 0x7ff: return m ? FP_NAN : FP_INFINITE; } } #include <assert.h> #include <stdlib.h> int main(void) { assert(FP_ZERO == xfpclassify(atof("0.0"))); assert(FP_ZERO == xfpclassify(atof("-0.0"))); assert(FP_NORMAL == xfpclassify(atof("1.0"))); assert(FP_NORMAL == xfpclassify(atof("-1.0"))); assert(FP_INFINITE == xfpclassify(atof("inf"))); assert(FP_INFINITE == xfpclassify(atof("-inf"))); assert(FP_NAN == xfpclassify(atof("nan"))); assert(FP_NAN == xfpclassify(atof("-nan"))); assert(FP_SUBNORMAL == xfpclassify(atof("1.8011670033376514e-308"))); return 0; }
* build: Fix -Wconversion warnings for fpclassify et alJustin M. Keyes2019-01-21
closes #8274 The parent commit tries a different approach, but that fails on Apple Clang version: Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin17.7.0 which somehow compiles the check_c_source_compiles() check, but then complains during later compilation that __fpclassify is not defined (regardless of "#include <math.h>").