OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / math / Half.h
1 /*\r
2 * Copyright (c) 2007-2010 SlimDX Group\r
3\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
5 * of this software and associated documentation files (the "Software"), to deal\r
6 * in the Software without restriction, including without limitation the rights\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
8 * copies of the Software, and to permit persons to whom the Software is\r
9 * furnished to do so, subject to the following conditions:\r
10\r
11 * The above copyright notice and this permission notice shall be included in\r
12 * all copies or substantial portions of the Software.\r
13\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
20 * THE SOFTWARE.\r
21 */\r
22 #pragma once\r
23 \r
24 #include "../design/HalfConverter.h"\r
25 \r
26 namespace SlimDX\r
27 {\r
28         /// <summary>\r
29         /// A half precision (16 bit) floating point value.\r
30         /// </summary>\r
31         /// <unmanaged>D3DXFLOAT16</unmanaged>\r
32         [System::Serializable]\r
33         [System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]\r
34         [System::ComponentModel::TypeConverter( SlimDX::Design::HalfConverter::typeid )]\r
35         public value class Half\r
36         {\r
37         private:\r
38                 System::UInt16 m_Value;\r
39 \r
40                 static Half()\r
41                 {\r
42                         Half::Epsilon = D3DX_16F_EPSILON;\r
43                         Half::MaxValue = D3DX_16F_MAX;\r
44                         Half::MinValue = D3DX_16F_MIN;\r
45                 }\r
46 \r
47         public:\r
48                 /// <summary>\r
49                 /// Number of decimal digits of precision.\r
50                 /// </summary>\r
51                 literal int PrecisionDigits = D3DX_16F_DIG;\r
52 \r
53                 /// <summary>\r
54                 /// Number of bits in the mantissa.\r
55                 /// </summary>\r
56                 literal int MantissaBits = D3DX_16F_MANT_DIG;\r
57 \r
58                 /// <summary>\r
59                 /// Maximum decimal exponent.\r
60                 /// </summary>\r
61                 literal int MaximumDecimalExponent = D3DX_16F_MAX_10_EXP;\r
62 \r
63                 /// <summary>\r
64                 /// Maximum binary exponent.\r
65                 /// </summary>\r
66                 literal int MaximumBinaryExponent = D3DX_16F_MAX_EXP;\r
67 \r
68                 /// <summary>\r
69                 /// Minimum decimal exponent.\r
70                 /// </summary>\r
71                 literal int MinimumDecimalExponent = D3DX_16F_MIN_10_EXP;\r
72 \r
73                 /// <summary>\r
74                 /// Minimum binary exponent.\r
75                 /// </summary>\r
76                 literal int MinimumBinaryExponent = D3DX_16F_MIN_EXP;\r
77 \r
78                 /// <summary>\r
79                 /// Exponent radix.\r
80                 /// </summary>\r
81                 literal int ExponentRadix = D3DX_16F_RADIX;\r
82 \r
83                 /// <summary>\r
84                 /// Additional rounding.\r
85                 /// </summary>\r
86                 literal int AdditionRounding = D3DX_16F_ROUNDS;\r
87 \r
88                 /// <summary>\r
89                 /// Smallest such that 1.0 + epsilon != 1.0\r
90                 /// </summary>\r
91                 static initonly float Epsilon;\r
92 \r
93                 /// <summary>\r
94                 /// Maximum value of the number.\r
95                 /// </summary>\r
96                 static initonly float MaxValue;\r
97 \r
98                 /// <summary>\r
99                 /// Minimum value of the number.\r
100                 /// </summary>\r
101                 static initonly float MinValue;\r
102 \r
103                 /// <summary>\r
104                 /// Initializes a new instance of the <see cref="Half"/> structure.\r
105                 /// </summary>\r
106                 /// <param name="value">The floating point value that should be stored in 16 bit format.</param>\r
107                 Half( float value );\r
108 \r
109                 /// <summary>\r
110                 /// Gets or sets the raw 16 bit value used to back this half-float.\r
111                 /// </summary>\r
112                 property System::UInt16 RawValue\r
113                 {\r
114                         System::UInt16 get();\r
115                         void set( System::UInt16 value );\r
116                 }\r
117 \r
118                 /// <summary>\r
119                 /// Converts an array of half precision values into full precision values.\r
120                 /// </summary>\r
121                 /// <param name="values">The values to be converted.</param>\r
122                 /// <returns>An array of converted values.</returns>\r
123                 static array<float>^ ConvertToFloat( array<Half>^ values );\r
124 \r
125                 /// <summary>\r
126                 /// Converts an array of full precision values into half precision values.\r
127                 /// </summary>\r
128                 /// <param name="values">The values to be converted.</param>\r
129                 /// <returns>An array of converted values.</returns>\r
130                 static array<Half>^ ConvertToHalf( array<float>^ values );\r
131 \r
132                 /// <summary>\r
133                 /// Performs an explicit conversion from <see cref="System::Single"/> to <see cref="Half"/>.\r
134                 /// </summary>\r
135                 /// <param name="value">The value to be converted.</param>\r
136                 /// <returns>The converted value.</returns>\r
137                 static explicit operator Half( float value );\r
138 \r
139                 /// <summary>\r
140                 /// Performs an implicit conversion from <see cref="Half"/> to <see cref="System::Single"/>.\r
141                 /// </summary>\r
142                 /// <param name="value">The value to be converted.</param>\r
143                 /// <returns>The converted value.</returns>\r
144                 static operator float( Half value );\r
145 \r
146                 /// <summary>\r
147                 /// Tests for equality between two objects.\r
148                 /// </summary>\r
149                 /// <param name="left">The first value to compare.</param>\r
150                 /// <param name="right">The second value to compare.</param>\r
151                 /// <returns><c>true</c> if <paramref name="left"/> has the same value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>\r
152                 static bool operator == ( Half left, Half right );\r
153 \r
154                 /// <summary>\r
155                 /// Tests for inequality between two objects.\r
156                 /// </summary>\r
157                 /// <param name="left">The first value to compare.</param>\r
158                 /// <param name="right">The second value to compare.</param>\r
159                 /// <returns><c>true</c> if <paramref name="left"/> has a different value than <paramref name="right"/>; otherwise, <c>false</c>.</returns>\r
160                 static bool operator != ( Half left, Half right );\r
161 \r
162                 /// <summary>\r
163                 /// Converts the value of the object to its equivalent string representation.\r
164                 /// </summary>\r
165                 /// <returns>The string representation of the value of this instance.</returns>\r
166                 virtual System::String^ ToString() override;\r
167 \r
168                 /// <summary>\r
169                 /// Returns the hash code for this instance.\r
170                 /// </summary>\r
171                 /// <returns>A 32-bit signed integer hash code.</returns>\r
172                 virtual int GetHashCode() override;\r
173 \r
174                 /// <summary>\r
175                 /// Returns a value that indicates whether the current instance is equal to a specified object. \r
176                 /// </summary>\r
177                 /// <param name="obj">Object to make the comparison with.</param>\r
178                 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>\r
179                 virtual bool Equals( System::Object^ obj ) override;\r
180 \r
181                 /// <summary>\r
182                 /// Returns a value that indicates whether the current instance is equal to the specified object. \r
183                 /// </summary>\r
184                 /// <param name="other">Object to make the comparison with.</param>\r
185                 /// <returns><c>true</c> if the current instance is equal to the specified object; <c>false</c> otherwise.</returns>\r
186                 virtual bool Equals( Half other );\r
187 \r
188                 /// <summary>\r
189                 /// Determines whether the specified object instances are considered equal. \r
190                 /// </summary>\r
191                 /// <param name="value1"></param>\r
192                 /// <param name="value2"></param>\r
193                 /// <returns><c>true</c> if <paramref name="value1"/> is the same instance as <paramref name="value2"/> or \r
194                 /// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>\r
195                 static bool Equals( Half% value1, Half% value2 );\r
196         };\r
197 }