-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities_impl.cpp
More file actions
46 lines (39 loc) · 795 Bytes
/
utilities_impl.cpp
File metadata and controls
46 lines (39 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "utilities.h"
namespace zymns
{
int mod( int m, int n )
{
if( n != 0 )
{
int r = m % n;
if( r < 0 )
r += n;
return r;
}
else
{
cerr << "The dividend shouldn't be zero." << endl;
return 0;
}
}
/**
* Rounds the elements of a/b to the nearest integers
* greater than or equal to a/b.
* e.g. ceil(10,2) = 5, ceil(10,3)=4.
*/
int ceil( int m, int n )
{
if( n != 0 )
{
int q = m / n;
if( m%n != 0 )
q += 1;
return q;
}
else
{
cerr << "The dividend shouldn't be zero." << endl;
return 0;
}
}
}