Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563580 views
1
#include "typedef.h"
2
#include "tools.h"
3
/**************************************************************************\
4
@---------------------------------------------------------------------------
5
@---------------------------------------------------------------------------
6
@ FILE: min_div.c
7
@---------------------------------------------------------------------------
8
@---------------------------------------------------------------------------
9
@
10
\**************************************************************************/
11
12
13
/*
14
@-------------------------------------------------------------------------
15
@ int min_div(a,b)
16
@ int a,b;
17
@
18
| Bestimmt c so, dass a = c * b + r mit minimalem r (im Absolutbetrag)
19
@ calculates intger c such that a = c*b + r with r of minimal absulute
20
@ size
21
@
22
@-------------------------------------------------------------------------
23
*/
24
25
int min_div(a,b)
26
int a,b;
27
{
28
int vorzeichen;
29
int c = 0;
30
31
if(a == 0) {
32
return(c);
33
}
34
if(b == 0) {
35
printf("Division durch NULL\n");
36
exit(3);
37
}
38
else {
39
/* was ein Quatsch vorzeichen = ((b > 0) == (a > 0)) ? 1 : -1; */
40
c = a/b;
41
if( abs((a - c * b) * 2) > abs(b) )
42
{
43
c += c > 0 ? 1 : -1;
44
}
45
/* s.o. c *= vorzeichen; */
46
}
47
return(c);
48
}
49
50
51
52
/*{{{}}}*/
53
54