GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "tools.h"2/**************************************************************************\3@---------------------------------------------------------------------------4@---------------------------------------------------------------------------5@ FILE: min_div.c6@---------------------------------------------------------------------------7@---------------------------------------------------------------------------8@9\**************************************************************************/101112/*13@-------------------------------------------------------------------------14@ int min_div(a,b)15@ int a,b;16@17| Bestimmt c so, dass a = c * b + r mit minimalem r (im Absolutbetrag)18@ calculates intger c such that a = c*b + r with r of minimal absulute19@ size20@21@-------------------------------------------------------------------------22*/2324int min_div(a,b)25int a,b;26{27int vorzeichen;28int c = 0;2930if(a == 0) {31return(c);32}33if(b == 0) {34printf("Division durch NULL\n");35exit(3);36}37else {38/* was ein Quatsch vorzeichen = ((b > 0) == (a > 0)) ? 1 : -1; */39c = a/b;40if( abs((a - c * b) * 2) > abs(b) )41{42c += c > 0 ? 1 : -1;43}44/* s.o. c *= vorzeichen; */45}46return(c);47}48495051/*{{{}}}*/525354