3 /*-------------------------------------------------------------------------
4 * drawElements Base Portability Library
5 * -------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Basic mathematical operations.
24 *//*--------------------------------------------------------------------*/
26 #include "deFloat16.h"
31 DE_INLINE double deToDouble (deFloat16 x) { return deFloat16To64(x); }
32 DE_INLINE double deToDouble (float x) { return x; };
33 DE_INLINE double deToDouble (double x) { return x; };
36 inline T deToFloatType(double x)
38 return static_cast<T>(x);
42 inline deFloat16 deToFloatType<deFloat16>(double x)
44 return deFloat64To16(x);
47 // These helpers make the C helpers usable from templates. Because some of
48 // these deal with signaling NaN, it's important that no implicit float
49 // conversion operations happen.
50 DE_INLINE deBool deIsPositiveZero (deFloat16 x) { return deHalfIsPositiveZero(x); };
51 DE_INLINE deBool deIsPositiveZero (float x) { return deFloatIsPositiveZero(x); };
52 DE_INLINE deBool deIsPositiveZero (double x) { return deDoubleIsPositiveZero(x); };
53 DE_INLINE deBool deIsNegativeZero (deFloat16 x) { return deHalfIsNegativeZero(x); };
54 DE_INLINE deBool deIsNegativeZero (float x) { return deFloatIsNegativeZero(x); };
55 DE_INLINE deBool deIsNegativeZero (double x) { return deDoubleIsNegativeZero(x); };
56 DE_INLINE deBool deIsIEEENaN (deFloat16 x) { return deHalfIsIEEENaN(x); };
57 DE_INLINE deBool deIsIEEENaN (float x) { return deFloatIsIEEENaN(x); };
58 DE_INLINE deBool deIsIEEENaN (double x) { return deDoubleIsIEEENaN(x); };
59 DE_INLINE deBool deIsSignalingNaN (deFloat16 x) { return deHalfIsSignalingNaN(x); };
60 DE_INLINE deBool deIsSignalingNaN (float x) { return deFloatIsSignalingNaN(x); };
61 DE_INLINE deBool deIsSignalingNaN (double x) { return deDoubleIsSignalingNaN(x); };
62 DE_INLINE deBool deIsQuietNaN (deFloat16 x) { return deHalfIsQuietNaN(x); };
63 DE_INLINE deBool deIsQuietNaN (float x) { return deFloatIsQuietNaN(x); };
64 DE_INLINE deBool deIsQuietNaN (double x) { return deDoubleIsQuietNaN(x); };
69 return std::numeric_limits<T>::quiet_NaN();
73 inline deFloat16 deQuietNaN<deFloat16>()
75 return deFloat16QuietNaN;
79 inline T deSignalingNaN()
81 return std::numeric_limits<T>::signaling_NaN();
85 inline deFloat16 deSignalingNaN<deFloat16>()
87 return deFloat16SignalingNaN;