aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/math/test/cases/NearbyInt.sql
blob: f27a93d727410a17e59e2cfdf9e645bfe0169c9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$f = ($mode)->{
    return (
        Math::NearbyInt(Double("NaN"),$mode),
        Math::NearbyInt(1e100,$mode),
        Math::NearbyInt(2.3,$mode),
        Math::NearbyInt(2.5,$mode),
        Math::NearbyInt(2.7,$mode),
        Math::NearbyInt(3.5,$mode),
        Math::NearbyInt(-1e100,$mode),
        Math::NearbyInt(-2.3,$mode),
        Math::NearbyInt(-2.5,$mode),
        Math::NearbyInt(-2.7,$mode),
        Math::NearbyInt(-3.5,$mode)
    )
};

select $f(Math::RoundDownward()), 0 as x
union all
select $f(Math::RoundToNearest()), 1 as x
union all
select $f(Math::RoundTowardZero()), 2 as x
union all
select $f(Math::RoundUpward()), 3 as x
order by x;