1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: math_Constant.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 24882 $ 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; // ネピア数 (自然対数の底) 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; // π 31 const f32 F_SQRTPI = 1.772453850905516f; // sqrt(π) 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; // 最大の正の数 = 3.40282346638529 * 10^38 39 const f32 F_MIN = FLT_MIN; // 最小の正の数 = 1.17549435082229 * 10^-38 40 41 42 #ifdef __ARMCC_VERSION 43 // ARMコンパイラの拡張機能を用いた定義 44 const f32 F_NAN = 0f_7FFFFFFF; // 非数 45 const f32 F_INF = 0f_7F800000; // ∞ 46 const f32 F_NINF = 0f_FF800000; // -∞ 47 const f32 F_ULP = 0f_34000000; // 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); // 非数 59 const f32 F_INF = *reinterpret_cast<const f32*>(&internal::I_INF); // ∞ 60 const f32 F_NINF = *reinterpret_cast<const f32*>(&internal::I_NINF); // -∞ 61 const f32 F_ULP = *reinterpret_cast<const f32*>(&internal::I_ULP); // 1.0f + x != 1.0f を満たす最小の正の値 62 63 #endif // __ARMCC_VERSION 64 65 }} // nn::math 66 67 /* NN_MATH_CONSTANT_H_ */ 68 #endif 69