[libc-commits] [libc] [libc][math] Add shared functions to check exceptions for exp* functions. (PR #202503)
Hubert Tong via libc-commits
libc-commits at lists.llvm.org
Fri Jun 19 19:26:29 PDT 2026
================
@@ -0,0 +1,84 @@
+//===-- Check exceptions for exp functions ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CHECK_EXP_EXCEPTIONS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CHECK_EXP_EXCEPTIONS_H
+
+#include "hdr/fenv_macros.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+namespace check {
+
+namespace exp_internal {
+
+template <typename T> struct Bounds;
+
+template <> struct Bounds<float> {
+ // Smallest value that will cause overflow, generated from Sollya:
+ // > float_max = 2^127 * (2 - 2^-23);
+ // > upper = round(log(float_max), SG, RU);
+ // > printfloat(upper);
----------------
hubert-reinterpretcast wrote:
While the numeric result is the same, I believe the calculation should have been done for `2^127 * (2 - 2^-23 + 2^-24)` to allow rounding down of the result by 0.5ulp. That is, determination of overflow or underflow should be based on the error in the result.
https://github.com/llvm/llvm-project/pull/202503
More information about the libc-commits
mailing list