constants.h
1 /* 2 * Copyright (C) 2018-2020, Advanced Micro Devices, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 1. Redistributions of source code must retain the above copyright notice, 7 * this list of conditions and the following disclaimer. 8 * 2. Redistributions in binary form must reproduce the above copyright notice, 9 * this list of conditions and the following disclaimer in the documentation 10 * and/or other materials provided with the distribution. 11 * 3. Neither the name of the copyright holder nor the names of its contributors 12 * may be used to endorse or promote products derived from this software without 13 * specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 21 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * POSSIBILITY OF SUCH DAMAGE. 25 * 26 */ 27 28 #ifndef __LIBM_CONSTANTS_H__ 29 #define __LIBM_CONSTANTS_H__ 30 31 /* 32 * Double precision - alias bin64,flt64 33 */ 34 35 #define ALM_F64_SIGN_SIZE 1 36 #define ALM_F64_SIGN_SHIFT 63 37 #define ALM_F64_SIGN_MASK (1ULL << ALM_F64_SIGN_SHIFT) 38 39 #define ALM_F64_EXPO_SIZE 11 40 #define ALM_F64_EXPO_SHIFT 52 41 #define ALM_F64_EXPO_MASK (((1ULL << ALM_F64_EXPO_SIZE) - 1) << ALM_F64_EXPO_SHIFT) 42 43 #define ALM_F64_MANT_SIZE (52) 44 #define ALM_F64_MANT_SHIFT 0 45 #define ALM_F64_MANT_MASK (((1ULL << ALM_F64_MANT_SIZE) - 1) << ALM_F64_MANT_SHFIT) 46 47 #define ALM_F64_EXP_MIN -1022 48 #define ALM_F64_EXP_MAX 1023 49 #define ALM_F64_EXP_BIASMAX 2046 50 #define ALM_F64_EXP_BIASMIN 1 51 52 #define ALM_F64_INF 0x7FF0000000000000ULL 53 #define ALM_F64_NINF 0xFFF0000000000000ULL 54 #define ALM_F64_NAN 0x7FF8000000000000ULL 55 56 #define ALM_F64_MIN 0x1.0000000000000p-1022 57 #define ALM_F64_MAX 0x1.fffffffffffffp+1023 58 59 60 /* 61 * Single precision - alias bin32,flt32 62 */ 63 64 #define ALM_F32_SIGN_SIZE 1 65 #define ALM_F32_SIGN_SHIFT 31 66 #define ALM_F32_SIGN_MASK (1ULL << ALM_F32_SIGN_SHIFT) 67 68 #define ALM_F32_EXPO_SIZE 8 69 #define ALM_F32_EXPO_SHIFT 23 70 #define ALM_F32_EXPO_MASK (((1ULL << ALM_F32_EXPO_SIZE) - 1) << ALM_F32_EXPO_SHIFT) 71 72 #define ALM_F32_MANT_SIZE 23 73 #define ALM_F32_MANT_SHIFT 0 74 #define ALM_F32_MANT_MASK (((1ULL << ALM_F32_MANT_SIZE) - 1) << ALM_F32_MANT_SHFIT) 75 76 77 #define ALM_F32_EXP_MIN -128 78 #define ALM_F32_EXP_MAX 127 79 #define ALM_F32_EXP_BIASMAX 256 80 #define ALM_F32_EXP_BIASMIN 1 81 82 #define ALM_F32_INF 0x7FF00000 83 #define ALM_F32_INF_MASK 0x7F800000 84 #define ALM_F32_NINF 0xFFF00000 85 #define ALM_F32_NAN 0x7FF80000 86 87 #define ALM_F32_MIN 0x1.0p-126f 88 #define ALM_F32_MAX 0x1.fffffep127f 89 90 91 #endif /* LIBM_CONSTANTS_H */ 92