1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: math_Constant.h 4 Copyright (C)2009-2010 Nintendo Co., Ltd. All rights reserved. 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 $Revision: 24882 $ 11 *--------------------------------------------------------------------------- 12 13 14 */ 15 16 #ifndef NN_MATH_CONSTANT_H_ 17 #define NN_MATH_CONSTANT_H_ 18 19 #include <cfloat> 20 #include <nn/math/math_Config.h> 21 22 namespace nn { namespace math { 23 24 25 const f32 F_E = 2.718281828459045f; // Napier's constant (natural log base) e 26 const f32 F_LOG2E = 1.442695040888963f; // log2(e) 27 const f32 F_LOG10E = 0.434294481903251f; // log10(e) 28 const f32 F_LN2 = 0.693147180559945f; // ln(2) 29 const f32 F_LN10 = 2.302585092994045f; // ln(10) 30 const f32 F_PI = 3.141592653589793f; // pi 31 const f32 F_SQRTPI = 1.772453850905516f; // sqrt(pi) 32 const f32 F_SQRT2 = 1.414213562373095f; // sqrt(2) 33 const f32 F_SQRT3 = 1.732050807568877f; // sqrt(3) 34 35 const f32 F_INVLN2 = 1.442695040888963f; // 1/ln2 36 37 38 const f32 F_MAX = FLT_MAX; // Maximum positive number = 3.40282346638529 * 10^38 39 const f32 F_MIN = FLT_MIN; // Minimum positive value = 1.17549435082229 * 10^-38 40 41 42 #ifdef __ARMCC_VERSION 43 // Definitions that use extended functionality of ARM compiler 44 const f32 F_NAN = 0f_7FFFFFFF; // Non-numbers 45 const f32 F_INF = 0f_7F800000; // Infinity 46 const f32 F_NINF = 0f_FF800000; // Negative infinity 47 const f32 F_ULP = 0f_34000000; // Minimum positive value that satisfies 1.0f + x != 1.0f 48 49 #else // __ARMCC_VERSION 50 namespace internal 51 { 52 const u32 I_NAN = 0x7FFFFFFF; // sign=+ exp=max frac=max 53 const u32 I_INF = 0x7F800000; // sign=+ exp=max frac=0 54 const u32 I_NINF = 0xFF800000; // sign=- exp=max frac=0 55 const u32 I_ULP = 0x34000000; // sign=+ exp=-23 frac=0 56 } /* namespace internal */ 57 58 const f32 F_NAN = *reinterpret_cast<const f32*>(&internal::I_NAN); // Non-numbers 59 const f32 F_INF = *reinterpret_cast<const f32*>(&internal::I_INF); // Infinity 60 const f32 F_NINF = *reinterpret_cast<const f32*>(&internal::I_NINF); // Negative infinity 61 const f32 F_ULP = *reinterpret_cast<const f32*>(&internal::I_ULP); // Minimum positive value that satisfies 1.0f + x != 1.0f 62 63 #endif // __ARMCC_VERSION 64 65 }} // nn::math 66 67 /* NN_MATH_CONSTANT_H_ */ 68 #endif 69