29 lines · cpp
1//===-- lib/quadmath/scale.cpp ----------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "math-entries.h"10#include "numeric-template-specs.h"11#include <limits>12 13namespace Fortran::runtime {14extern "C" {15 16#if HAS_LDBL128 || HAS_FLOAT12817F128Type RTDEF(Scale16)(F128Type x, std::int64_t p) {18 auto ip{static_cast<int>(p)};19 if (ip != p) {20 ip = p < 0 ? std::numeric_limits<int>::min()21 : std::numeric_limits<int>::max();22 }23 return LDEXPTy<F128Type>::compute(x, ip);24}25#endif26 27} // extern "C"28} // namespace Fortran::runtime29