// Copyright (C) 2024-2025 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . // { dg-do run { target c++23 } } // { dg-require-cmath "" } #include #include #include #include template void test () { using lim = std::numeric_limits; int t0 = std::ilogb(T(4.0)); VERIFY( t0 == 2 ); int t1 = std::ilogb(lim::infinity()); VERIFY( t1 == std::numeric_limits::max() ); int t2 = std::ilogb(-lim::infinity()); VERIFY( t2 == std::numeric_limits::max() ); } int main () { #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) test (); #endif #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) test (); #endif #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) test (); #endif #if defined(__STDCPP_FLOAT128_T__) \ && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) test (); #endif #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) test (); #endif }