/************************************************************************/ /* * The Rocq Prover / The Rocq Development Team */ /* v * Copyright INRIA, CNRS and contributors */ /* <O___,, * (see version control and CREDITS file for authors & dates) */ /* \VV/ **************************************************************/ /* // * This file is distributed under the terms of the */ /* * GNU Lesser General Public License Version 2.1 */ /* * (see LICENSE file for the text of the license) */ /************************************************************************/
#include <math.h> #include <stdint.h>
#define CAML_INTERNALS #include <caml/alloc.h>
#include"rocq_values.h"
union double_bits { double d;
uint64_t u;
};
staticdouble next_up(double x) { union double_bits bits; if (!(x < INFINITY)) return x; // x is +oo or NaN
bits.d = x;
int64_t i = bits.u; if (i >= 0) ++bits.u; // x >= +0.0, go away from zero elseif (bits.u + bits.u == 0) bits.u = 1; // x is -0.0, should almost never happen else --bits.u; // x < 0.0, go toward zero return bits.d;
}
staticdouble next_down(double x) { union double_bits bits; if (!(x > -INFINITY)) return x; // x is -oo or NaN
bits.d = x;
int64_t i = bits.u; if (i == 0) bits.u = INT64_MIN + 1; // x is +0.0 elseif (i < 0) ++bits.u; // x <= -0.0, go away from zero else --bits.u; // x > 0.0, go toward zero return bits.d;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.