1 /* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
20 #ifndef EINA_INLINE_FP_X_
21 # define EINA_INLINE_FP_X_
23 static inline Eina_F32p32
24 eina_f32p32_int_from(int32_t v)
26 return (Eina_F32p32)(v) << 32;
30 eina_f32p32_int_to(Eina_F32p32 v)
32 return (int32_t)(v >> 32);
35 static inline Eina_F32p32
36 eina_f32p32_double_from(double v)
39 r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5));
44 eina_f32p32_double_to(Eina_F32p32 v)
53 static inline Eina_F16p16
54 eina_f16p16_int_from(int32_t v)
60 eina_f16p16_int_to(Eina_F16p16 v)
65 static inline Eina_F16p16
66 eina_f16p16_float_from(float v)
70 r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f));
75 eina_f16p16_float_to(Eina_F16p16 v)
85 static inline Eina_F8p24
86 eina_f8p24_int_from(int32_t v)
92 eina_f8p24_int_to(Eina_F8p24 v)
97 static inline Eina_F8p24
98 eina_f8p24_float_from(float v)
102 r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f));
107 eina_f8p24_float_to(Eina_F8p24 v)
117 static inline Eina_F32p32
118 eina_f16p16_to_f32p32(Eina_F16p16 a)
120 return ((Eina_F32p32) a) << 16;
123 static inline Eina_F32p32
124 eina_f8p24_to_f32p32(Eina_F8p24 a)
126 return ((Eina_F32p32) a) << 8;
129 static inline Eina_F16p16
130 eina_f32p32_to_f16p16(Eina_F32p32 a)
132 return (Eina_F16p16) (a >> 16);
135 static inline Eina_F16p16
136 eina_f8p24_to_f16p16(Eina_F8p24 a)
138 return (Eina_F16p16) (a >> 8);
141 static inline Eina_F8p24
142 eina_f32p32_to_f8p24(Eina_F32p32 a)
144 return (Eina_F8p24) (a >> 8);
147 static inline Eina_F8p24
148 eina_f16p16_to_f8p24(Eina_F16p16 a)
150 return (Eina_F8p24) (a << 8);