[libc-commits] [libc] [libc][math] Make pow function correctly rounded for all rounding modes. (PR #222827)
via libc-commits
libc-commits at lists.llvm.org
Thu Sep 17 10:57:01 PDT 2026
================
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declaration of 256-bit unsigned fractional type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_FRAC256_H
+#define LLVM_LIBC_SRC___SUPPORT_FRAC256_H
+
+#include "big_int.h"
+#include "frac128.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+struct Frac256 : public UInt<256> {
+ using UInt<256>::UInt;
+
+ // Convert Frac256 number to Frac128 with truncation.
+ LIBC_INLINE constexpr Frac128 to_frac128() const {
+ return Frac128({val[2], val[3]});
+ }
+
+ LIBC_INLINE constexpr explicit operator Frac128() const {
+ return to_frac128();
+ }
+
+ // Convert Frac256 number to Frac64 with truncation.
+ LIBC_INLINE constexpr Frac64 to_frac64() const { return Frac64(val[3]); }
+
+ LIBC_INLINE constexpr explicit operator Frac64() const { return to_frac64(); }
+
+ LIBC_INLINE constexpr Frac256 operator~() const {
+ Frac256 r{};
+ r.val[0] = ~val[0];
+ r.val[1] = ~val[1];
+ r.val[2] = ~val[2];
+ r.val[3] = ~val[3];
+ return r;
+ }
+
+ LIBC_INLINE constexpr Frac256 operator+(const Frac256 &other) const {
+ UInt<256> r = UInt<256>(*this) + (UInt<256>(other));
+ return Frac256(r.val);
+ }
+
+ LIBC_INLINE constexpr Frac256 operator-(const Frac256 &other) const {
+ UInt<256> r = UInt<256>(*this) - (UInt<256>(other));
----------------
lntue wrote:
Done.
https://github.com/llvm/llvm-project/pull/222827
More information about the libc-commits
mailing list