lean2/src/util/numerics/remainder.h
Leonardo de Moura 1429cc9df2 feat(numerics): add finite field Z/pZ
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-10-18 13:27:28 -07:00

20 lines
395 B
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include "util/debug.h"
namespace lean {
template<class T>
T remainder(T a, T b) {
lean_assert(b != 0);
if (a > 0)
return a % b;
else if (b > 0)
return a % b + b;
else
return a % b - b;
}
}