1 | <html> |
---|
2 | <head> |
---|
3 | <title>OgreBitwise.h Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
4 | <link type="text/css" rel="stylesheet" href="style.css"> |
---|
5 | </head> |
---|
6 | |
---|
7 | <body> |
---|
8 | <!-- Generated by Doxygen 1.3.6 --> |
---|
9 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
---|
10 | <h1>OgreBitwise.h</h1><a href="OgreBitwise_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span> |
---|
11 | 00002 <span class="comment">-----------------------------------------------------------------------------</span> |
---|
12 | 00003 <span class="comment">This source file is part of OGRE</span> |
---|
13 | 00004 <span class="comment"> (Object-oriented Graphics Rendering Engine)</span> |
---|
14 | 00005 <span class="comment">For the latest info, see http://www.ogre3d.org/</span> |
---|
15 | 00006 <span class="comment"></span> |
---|
16 | 00007 <span class="comment">Copyright (c) 2000-2005 The OGRE Team</span> |
---|
17 | 00008 <span class="comment">Also see acknowledgements in Readme.html</span> |
---|
18 | 00009 <span class="comment"></span> |
---|
19 | 00010 <span class="comment">This program is free software; you can redistribute it and/or modify it under</span> |
---|
20 | 00011 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</span> |
---|
21 | 00012 <span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span> |
---|
22 | 00013 <span class="comment">version.</span> |
---|
23 | 00014 <span class="comment"></span> |
---|
24 | 00015 <span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</span> |
---|
25 | 00016 <span class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span> |
---|
26 | 00017 <span class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span> |
---|
27 | 00018 <span class="comment"></span> |
---|
28 | 00019 <span class="comment">You should have received a copy of the GNU Lesser General Public License along with</span> |
---|
29 | 00020 <span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span> |
---|
30 | 00021 <span class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</span> |
---|
31 | 00022 <span class="comment">http://www.gnu.org/copyleft/lesser.txt.</span> |
---|
32 | 00023 <span class="comment">-----------------------------------------------------------------------------</span> |
---|
33 | 00024 <span class="comment">*/</span> |
---|
34 | 00025 <span class="preprocessor">#ifndef _Bitwise_H__</span> |
---|
35 | 00026 <span class="preprocessor"></span><span class="preprocessor">#define _Bitwise_H__</span> |
---|
36 | 00027 <span class="preprocessor"></span> |
---|
37 | 00028 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span> |
---|
38 | 00029 |
---|
39 | 00030 <span class="keyword">namespace </span>Ogre { |
---|
40 | 00031 |
---|
41 | <a name="l00034"></a><a class="code" href="classOgre_1_1Bitwise.html">00034</a> <span class="keyword">class </span><a class="code" href="classOgre_1_1Bitwise.html">Bitwise</a> { |
---|
42 | 00035 <span class="keyword">public</span>: |
---|
43 | 00039 <span class="keyword">template</span><<span class="keyword">typename</span> T> |
---|
44 | <a name="l00040"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee0">00040</a> <span class="keyword">static</span> <a class="code" href="OgrePlatform_8h.html#a10">FORCEINLINE</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee0">getBitShift</a>(T mask) |
---|
45 | 00041 { |
---|
46 | 00042 <span class="keywordflow">if</span> (mask == 0) |
---|
47 | 00043 <span class="keywordflow">return</span> 0; |
---|
48 | 00044 |
---|
49 | 00045 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> result = 0; |
---|
50 | 00046 <span class="keywordflow">while</span> ((mask & 1) == 0) { |
---|
51 | 00047 ++result; |
---|
52 | 00048 mask >>= 1; |
---|
53 | 00049 } |
---|
54 | 00050 <span class="keywordflow">return</span> result; |
---|
55 | 00051 } |
---|
56 | 00052 |
---|
57 | 00058 <span class="keyword">template</span><<span class="keyword">typename</span> SrcT, <span class="keyword">typename</span> DestT> |
---|
58 | <a name="l00059"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee1">00059</a> <span class="keyword">static</span> <span class="keyword">inline</span> DestT <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee1">convertBitPattern</a>(SrcT srcValue, SrcT srcBitMask, DestT destBitMask) |
---|
59 | 00060 { |
---|
60 | 00061 <span class="comment">// Mask off irrelevant source value bits (if any)</span> |
---|
61 | 00062 srcValue = srcValue & srcBitMask; |
---|
62 | 00063 |
---|
63 | 00064 <span class="comment">// Shift source down to bottom of DWORD</span> |
---|
64 | 00065 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> srcBitShift = <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee0">getBitShift</a>(srcBitMask); |
---|
65 | 00066 srcValue >>= srcBitShift; |
---|
66 | 00067 |
---|
67 | 00068 <span class="comment">// Get max value possible in source from srcMask</span> |
---|
68 | 00069 <span class="keyword">const</span> SrcT srcMax = srcBitMask >> srcBitShift; |
---|
69 | 00070 |
---|
70 | 00071 <span class="comment">// Get max avaiable in dest</span> |
---|
71 | 00072 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> destBitShift = <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee0">getBitShift</a>(destBitMask); |
---|
72 | 00073 <span class="keyword">const</span> DestT destMax = destBitMask >> destBitShift; |
---|
73 | 00074 |
---|
74 | 00075 <span class="comment">// Scale source value into destination, and shift back</span> |
---|
75 | 00076 DestT destValue = (srcValue * destMax) / srcMax; |
---|
76 | 00077 <span class="keywordflow">return</span> (destValue << destBitShift); |
---|
77 | 00078 } |
---|
78 | 00079 |
---|
79 | <a name="l00084"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee2">00084</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee2">fixedToFixed</a>(<a class="code" href="namespaceOgre.html#a412">uint32</a> value, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> p) |
---|
80 | 00085 { |
---|
81 | 00086 <span class="keywordflow">if</span>(n > p) |
---|
82 | 00087 { |
---|
83 | 00088 <span class="comment">// Less bits required than available; this is easy</span> |
---|
84 | 00089 value >>= n-p; |
---|
85 | 00090 } |
---|
86 | 00091 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n < p) |
---|
87 | 00092 { |
---|
88 | 00093 <span class="comment">// More bits required than are there, do the fill</span> |
---|
89 | 00094 <span class="comment">// Use old fashioned division, probably better than a loop</span> |
---|
90 | 00095 <span class="keywordflow">if</span>(value == 0) |
---|
91 | 00096 value = 0; |
---|
92 | 00097 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(value == (static_cast<unsigned int>(1)<<n)-1) |
---|
93 | 00098 value = (1<<p)-1; |
---|
94 | 00099 <span class="keywordflow">else</span> value = value*(1<<p)/((1<<n)-1); |
---|
95 | 00100 } |
---|
96 | 00101 <span class="keywordflow">return</span> value; |
---|
97 | 00102 } |
---|
98 | 00103 |
---|
99 | <a name="l00108"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee3">00108</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee3">floatToFixed</a>(<span class="keyword">const</span> <span class="keywordtype">float</span> value, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bits) |
---|
100 | 00109 { |
---|
101 | 00110 <span class="keywordflow">if</span>(value <= 0.0f) <span class="keywordflow">return</span> 0; |
---|
102 | 00111 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (value >= 1.0f) <span class="keywordflow">return</span> (1<<bits)-1; |
---|
103 | 00112 <span class="keywordflow">else</span> <span class="keywordflow">return</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)(value * (1<<bits)); |
---|
104 | 00113 } |
---|
105 | 00114 |
---|
106 | <a name="l00118"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee4">00118</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee4">fixedToFloat</a>(<span class="keywordtype">unsigned</span> value, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bits) |
---|
107 | 00119 { |
---|
108 | 00120 <span class="keywordflow">return</span> (<span class="keywordtype">float</span>)value/(<span class="keywordtype">float</span>)((1<<bits)-1); |
---|
109 | 00121 } |
---|
110 | 00122 |
---|
111 | <a name="l00126"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee5">00126</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee5">intWrite</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *dest, <span class="keyword">const</span> <span class="keywordtype">int</span> n, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> value) |
---|
112 | 00127 { |
---|
113 | 00128 <span class="keywordflow">switch</span>(n) { |
---|
114 | 00129 <span class="keywordflow">case</span> 1: |
---|
115 | 00130 ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[0] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)value; |
---|
116 | 00131 <span class="keywordflow">break</span>; |
---|
117 | 00132 <span class="keywordflow">case</span> 2: |
---|
118 | 00133 ((<a class="code" href="namespaceOgre.html#a413">uint16</a>*)dest)[0] = (<a class="code" href="namespaceOgre.html#a413">uint16</a>)value; |
---|
119 | 00134 <span class="keywordflow">break</span>; |
---|
120 | 00135 <span class="keywordflow">case</span> 3: |
---|
121 | 00136 <span class="preprocessor">#if OGRE_ENDIAN == OGRE_ENDIAN_BIG </span> |
---|
122 | 00137 <span class="preprocessor"></span> ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[0] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)((value >> 16) & 0xFF); |
---|
123 | 00138 ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[1] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)((value >> 8) & 0xFF); |
---|
124 | 00139 ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[2] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)(value & 0xFF); |
---|
125 | 00140 <span class="preprocessor">#else</span> |
---|
126 | 00141 <span class="preprocessor"></span> ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[2] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)((value >> 16) & 0xFF); |
---|
127 | 00142 ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[1] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)((value >> 8) & 0xFF); |
---|
128 | 00143 ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)dest)[0] = (<a class="code" href="namespaceOgre.html#a414">uint8</a>)(value & 0xFF); |
---|
129 | 00144 <span class="preprocessor">#endif</span> |
---|
130 | 00145 <span class="preprocessor"></span> <span class="keywordflow">break</span>; |
---|
131 | 00146 <span class="keywordflow">case</span> 4: |
---|
132 | 00147 ((<a class="code" href="namespaceOgre.html#a412">uint32</a>*)dest)[0] = (<a class="code" href="namespaceOgre.html#a412">uint32</a>)value; |
---|
133 | 00148 <span class="keywordflow">break</span>; |
---|
134 | 00149 } |
---|
135 | 00150 } |
---|
136 | <a name="l00154"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee6">00154</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee6">intRead</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *src, <span class="keywordtype">int</span> n) { |
---|
137 | 00155 <span class="keywordflow">switch</span>(n) { |
---|
138 | 00156 <span class="keywordflow">case</span> 1: |
---|
139 | 00157 <span class="keywordflow">return</span> ((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[0]; |
---|
140 | 00158 <span class="keywordflow">case</span> 2: |
---|
141 | 00159 <span class="keywordflow">return</span> ((<a class="code" href="namespaceOgre.html#a413">uint16</a>*)src)[0]; |
---|
142 | 00160 <span class="keywordflow">case</span> 3: |
---|
143 | 00161 <span class="preprocessor">#if OGRE_ENDIAN == OGRE_ENDIAN_BIG </span> |
---|
144 | 00162 <span class="preprocessor"></span> <span class="keywordflow">return</span> ((<a class="code" href="namespaceOgre.html#a412">uint32</a>)((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[0]<<16)| |
---|
145 | 00163 ((<a class="code" href="namespaceOgre.html#a412">uint32</a>)((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[1]<<8)| |
---|
146 | 00164 ((<a class="code" href="namespaceOgre.html#a412">uint32</a>)((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[2]); |
---|
147 | 00165 <span class="preprocessor">#else</span> |
---|
148 | 00166 <span class="preprocessor"></span> <span class="keywordflow">return</span> ((<a class="code" href="namespaceOgre.html#a412">uint32</a>)((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[0])| |
---|
149 | 00167 ((<a class="code" href="namespaceOgre.html#a412">uint32</a>)((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[1]<<8)| |
---|
150 | 00168 ((<a class="code" href="namespaceOgre.html#a412">uint32</a>)((<a class="code" href="namespaceOgre.html#a414">uint8</a>*)src)[2]<<16); |
---|
151 | 00169 <span class="preprocessor">#endif</span> |
---|
152 | 00170 <span class="preprocessor"></span> <span class="keywordflow">case</span> 4: |
---|
153 | 00171 <span class="keywordflow">return</span> ((<a class="code" href="namespaceOgre.html#a412">uint32</a>*)src)[0]; |
---|
154 | 00172 } |
---|
155 | 00173 <span class="keywordflow">return</span> 0; <span class="comment">// ?</span> |
---|
156 | 00174 } |
---|
157 | 00175 |
---|
158 | <a name="l00179"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee7">00179</a> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a413">uint16</a> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee7">floatToHalf</a>(<span class="keywordtype">float</span> i) |
---|
159 | 00180 { |
---|
160 | 00181 <span class="keywordflow">return</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee8">floatToHalfI</a>(*reinterpret_cast<uint32*>(&i)); |
---|
161 | 00182 } |
---|
162 | <a name="l00185"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee8">00185</a> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a413">uint16</a> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee8">floatToHalfI</a>(<a class="code" href="namespaceOgre.html#a412">uint32</a> i) |
---|
163 | 00186 { |
---|
164 | 00187 <span class="keyword">register</span> <span class="keywordtype">int</span> s = (i >> 16) & 0x00008000; |
---|
165 | 00188 <span class="keyword">register</span> <span class="keywordtype">int</span> e = ((i >> 23) & 0x000000ff) - (127 - 15); |
---|
166 | 00189 <span class="keyword">register</span> <span class="keywordtype">int</span> m = i & 0x007fffff; |
---|
167 | 00190 |
---|
168 | 00191 <span class="keywordflow">if</span> (e <= 0) |
---|
169 | 00192 { |
---|
170 | 00193 <span class="keywordflow">if</span> (e < -10) |
---|
171 | 00194 { |
---|
172 | 00195 <span class="keywordflow">return</span> 0; |
---|
173 | 00196 } |
---|
174 | 00197 m = (m | 0x00800000) >> (1 - e); |
---|
175 | 00198 |
---|
176 | 00199 <span class="keywordflow">return</span> s | (m >> 13); |
---|
177 | 00200 } |
---|
178 | 00201 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e == 0xff - (127 - 15)) |
---|
179 | 00202 { |
---|
180 | 00203 <span class="keywordflow">if</span> (m == 0) <span class="comment">// Inf</span> |
---|
181 | 00204 { |
---|
182 | 00205 <span class="keywordflow">return</span> s | 0x7c00; |
---|
183 | 00206 } |
---|
184 | 00207 <span class="keywordflow">else</span> <span class="comment">// NAN</span> |
---|
185 | 00208 { |
---|
186 | 00209 m >>= 13; |
---|
187 | 00210 <span class="keywordflow">return</span> s | 0x7c00 | m | (m == 0); |
---|
188 | 00211 } |
---|
189 | 00212 } |
---|
190 | 00213 <span class="keywordflow">else</span> |
---|
191 | 00214 { |
---|
192 | 00215 <span class="keywordflow">if</span> (e > 30) <span class="comment">// Overflow</span> |
---|
193 | 00216 { |
---|
194 | 00217 <span class="keywordflow">return</span> s | 0x7c00; |
---|
195 | 00218 } |
---|
196 | 00219 |
---|
197 | 00220 <span class="keywordflow">return</span> s | (e << 10) | (m >> 13); |
---|
198 | 00221 } |
---|
199 | 00222 } |
---|
200 | 00223 |
---|
201 | <a name="l00228"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee9">00228</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee9">halfToFloat</a>(<a class="code" href="namespaceOgre.html#a413">uint16</a> y) |
---|
202 | 00229 { |
---|
203 | 00230 <a class="code" href="namespaceOgre.html#a412">uint32</a> r = <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee10">halfToFloatI</a>(y); |
---|
204 | 00231 <span class="keywordflow">return</span> *reinterpret_cast<float*>(&r); |
---|
205 | 00232 } |
---|
206 | <a name="l00236"></a><a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee10">00236</a> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="namespaceOgre.html#a412">uint32</a> <a class="code" href="classOgre_1_1Bitwise.html#Ogre_1_1Bitwisee10">halfToFloatI</a>(<a class="code" href="namespaceOgre.html#a413">uint16</a> y) |
---|
207 | 00237 { |
---|
208 | 00238 <span class="keyword">register</span> <span class="keywordtype">int</span> s = (y >> 15) & 0x00000001; |
---|
209 | 00239 <span class="keyword">register</span> <span class="keywordtype">int</span> e = (y >> 10) & 0x0000001f; |
---|
210 | 00240 <span class="keyword">register</span> <span class="keywordtype">int</span> m = y & 0x000003ff; |
---|
211 | 00241 |
---|
212 | 00242 <span class="keywordflow">if</span> (e == 0) |
---|
213 | 00243 { |
---|
214 | 00244 <span class="keywordflow">if</span> (m == 0) <span class="comment">// Plus or minus zero</span> |
---|
215 | 00245 { |
---|
216 | 00246 <span class="keywordflow">return</span> s << 31; |
---|
217 | 00247 } |
---|
218 | 00248 <span class="keywordflow">else</span> <span class="comment">// Denormalized number -- renormalize it</span> |
---|
219 | 00249 { |
---|
220 | 00250 <span class="keywordflow">while</span> (!(m & 0x00000400)) |
---|
221 | 00251 { |
---|
222 | 00252 m <<= 1; |
---|
223 | 00253 e -= 1; |
---|
224 | 00254 } |
---|
225 | 00255 |
---|
226 | 00256 e += 1; |
---|
227 | 00257 m &= ~0x00000400; |
---|
228 | 00258 } |
---|
229 | 00259 } |
---|
230 | 00260 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e == 31) |
---|
231 | 00261 { |
---|
232 | 00262 <span class="keywordflow">if</span> (m == 0) <span class="comment">// Inf</span> |
---|
233 | 00263 { |
---|
234 | 00264 <span class="keywordflow">return</span> (s << 31) | 0x7f800000; |
---|
235 | 00265 } |
---|
236 | 00266 <span class="keywordflow">else</span> <span class="comment">// NaN</span> |
---|
237 | 00267 { |
---|
238 | 00268 <span class="keywordflow">return</span> (s << 31) | 0x7f800000 | (m << 13); |
---|
239 | 00269 } |
---|
240 | 00270 } |
---|
241 | 00271 |
---|
242 | 00272 e = e + (127 - 15); |
---|
243 | 00273 m = m << 13; |
---|
244 | 00274 |
---|
245 | 00275 <span class="keywordflow">return</span> (s << 31) | (e << 23) | m; |
---|
246 | 00276 } |
---|
247 | 00277 |
---|
248 | 00278 |
---|
249 | 00279 }; |
---|
250 | 00280 } |
---|
251 | 00281 |
---|
252 | 00282 <span class="preprocessor">#endif</span> |
---|
253 | </pre></div><hr> |
---|
254 | <p> |
---|
255 | Copyright © 2000-2005 by The OGRE Team<br /> |
---|
256 | <!--Creative Commons License--><a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.png"/></a><br/> |
---|
257 | This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-ShareAlike 2.5 License</a>.<br/> |
---|
258 | <!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
---|
259 | <Work rdf:about=""> |
---|
260 | <license rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" /> |
---|
261 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" /> |
---|
262 | </Work> |
---|
263 | <License rdf:about="http://creativecommons.org/licenses/by-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License></rdf:RDF> --> |
---|
264 | |
---|
265 | Last modified Sun Feb 12 12:59:41 2006 |
---|
266 | </p> |
---|
267 | </body> |
---|
268 | </html> |
---|