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

◆ Multiply() [1/4]

static unsafe void System.Number.BigInteger.Multiply ( ref BigInteger lhs,
ref BigInteger rhs,
out BigInteger result )
inlinestatic

Definition at line 346 of file Number.cs.

347 {
348 if (lhs._length <= 1)
349 {
350 Multiply(ref rhs, lhs.ToUInt32(), out result);
351 return;
352 }
353 if (rhs._length <= 1)
354 {
355 Multiply(ref lhs, rhs.ToUInt32(), out result);
356 return;
357 }
358 ref BigInteger reference = ref lhs;
359 int length = lhs._length;
360 ref BigInteger reference2 = ref rhs;
361 int length2 = rhs._length;
362 if (length < length2)
363 {
364 reference = ref rhs;
365 length = rhs._length;
366 reference2 = ref lhs;
367 length2 = lhs._length;
368 }
369 int num = (result._length = length2 + length);
370 result.Clear((uint)num);
371 int num2 = 0;
372 int num3 = 0;
373 while (num2 < length2)
374 {
375 if (reference2._blocks[num2] != 0)
376 {
377 int num4 = 0;
378 int num5 = num3;
379 ulong num6 = 0uL;
380 do
381 {
382 ulong num7 = (ulong)(result._blocks[num5] + (long)reference2._blocks[num2] * (long)reference._blocks[num4]) + num6;
383 num6 = num7 >> 32;
384 result._blocks[num5] = (uint)num7;
385 num5++;
386 num4++;
387 }
388 while (num4 < length);
389 result._blocks[num5] = (uint)num6;
390 }
391 num2++;
392 num3++;
393 }
394 if (num > 0 && result._blocks[num - 1] == 0)
395 {
396 result._length--;
397 }
398 }

References System.Number.BigInteger._length, System.length, System.length2, and System.Multiply.