Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ BigInteger() [6/12]

System.Numerics.BigInteger.BigInteger ( double value)
inline

Definition at line 190 of file BigInteger.cs.

191 {
192 if (!double.IsFinite(value))
193 {
194 if (double.IsInfinity(value))
195 {
196 throw new OverflowException(System.SR.Overflow_BigIntInfinity);
197 }
198 throw new OverflowException(System.SR.Overflow_NotANumber);
199 }
200 _sign = 0;
201 _bits = null;
202 NumericsHelpers.GetDoubleParts(value, out var sign, out var exp, out var man, out var _);
203 if (man == 0L)
204 {
205 this = Zero;
206 return;
207 }
208 if (exp <= 0)
209 {
210 if (exp <= -64)
211 {
212 this = Zero;
213 return;
214 }
215 this = man >> -exp;
216 if (sign < 0)
217 {
218 _sign = -_sign;
219 }
220 return;
221 }
222 if (exp <= 11)
223 {
224 this = man << exp;
225 if (sign < 0)
226 {
227 _sign = -_sign;
228 }
229 return;
230 }
231 man <<= 11;
232 exp -= 11;
233 int num = (exp - 1) / 32 + 1;
234 int num2 = num * 32 - exp;
235 _bits = new uint[num + 2];
236 _bits[num + 1] = (uint)(man >> num2 + 32);
237 _bits[num] = (uint)(man >> num2);
238 if (num2 > 0)
239 {
240 _bits[num - 1] = (uint)((int)man << 32 - num2);
241 }
242 _sign = sign;
243 }
static string Overflow_NotANumber
Definition SR.cs:28
static string Overflow_BigIntInfinity
Definition SR.cs:26
Definition SR.cs:7
readonly uint[] _bits
Definition BigInteger.cs:20
static BigInteger Zero
Definition BigInteger.cs:32

References System.Numerics.BigInteger._bits, System.Numerics.BigInteger._sign, System.Numerics.NumericsHelpers.GetDoubleParts(), System.L, System.SR.Overflow_BigIntInfinity, System.SR.Overflow_NotANumber, System.value, and System.Numerics.BigInteger.Zero.