MCPcopy Create free account
hub / github.com/Singular/Singular / nr2mDiv

Function nr2mDiv

libpolys/coeffs/rmodulo2m.cc:427–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427static number nr2mDiv(number a, number b, const coeffs r)
428{
429 if ((unsigned long)a == 0) return (number)0;
430 else if ((unsigned long)b % 2 == 0)
431 {
432 if ((unsigned long)b != 0)
433 {
434 while (((unsigned long)b % 2 == 0) && ((unsigned long)a % 2 == 0))
435 {
436 a = (number)((unsigned long)a / 2);
437 b = (number)((unsigned long)b / 2);
438 }
439 }
440 if ((long)b==0L)
441 {
442 WerrorS(nDivBy0);
443 return (number)0L;
444 }
445 else if ((unsigned long)b % 2 == 0)
446 {
447 WerrorS("Division not possible, even by cancelling zero divisors.");
448 WerrorS("Result is integer division without remainder.");
449 return (number) ((unsigned long) a / (unsigned long) b);
450 }
451 }
452 number n=nr2mMult(a, nr2mInversM(b,r),r);
453 n_Test(n,r);
454 return n;
455}
456
457/* Is 'a' divisible by 'b'? There are two cases:
458 1) a = 0 mod 2^m; then TRUE iff b = 0 or b is a power of 2

Callers 2

nr2mDivByFunction · 0.85
nr2mReadFunction · 0.85

Calls 3

WerrorSFunction · 0.85
nr2mMultFunction · 0.85
nr2mInversMFunction · 0.85

Tested by

no test coverage detected