2 #include "compatibility.hh"
8 #if defined(WIN32) && ! defined(__MINGW32__)
9 /* missing on Windows : see http://bugs.mysql.com/bug.php?id=15936 */
10 inline double rint(double nr
)
14 return (((c
-nr
) >= (nr
- f
)) ? f
: c
);
18 class RintPrim
: public xtended
23 RintPrim() : xtended("rint") {}
25 virtual unsigned int arity () { return 1; }
27 virtual bool needCache () { return true; }
29 virtual Type
infereSigType (const vector
<Type
>& args
)
31 assert (args
.size() == arity());
32 interval i
= args
[0]->getInterval();
34 return castInterval(floatCast(args
[0]), interval(rint(i
.lo
), rint(i
.hi
)));
36 return floatCast(args
[0]);
40 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
42 virtual int infereSigOrder (const vector
<int>& args
) {
43 assert (args
.size() == arity());
48 virtual Tree
computeSigOutput (const vector
<Tree
>& args
) {
50 assert (args
.size() == arity());
51 if (isNum(args
[0],n
)) {
52 return tree(rint(double(n
)));
54 return tree(symbol(), args
[0]);
58 virtual string
generateCode (Klass
* klass
, const vector
<string
>& args
, const vector
<Type
>& types
)
60 assert (args
.size() == arity());
61 assert (types
.size() == arity());
63 return subst("rint$1($0)", args
[0], isuffix());
66 virtual string
generateLateq (Lateq
* lateq
, const vector
<string
>& args
, const vector
<Type
>& types
)
68 assert (args
.size() == arity());
69 assert (types
.size() == arity());
71 return subst("\\left[ {$0} \\right]", args
[0]);
77 xtended
* gRintPrim
= new RintPrim();