예제 #1
0
def trunc(x):
    if type(x) is types.sfix:
        return floatingpoint.Trunc(x.v, x.k - x.f, x.f, x.kappa)
    elif type(x) is types.sfloat:
        v, p, z, s = floatingpoint.FLRound(x, 0)
        return types.sfloat(v, p, z, s, x.err)
    return x
예제 #2
0
def trunc(x):
    if type(x) is types.sfix:
        return AdvInteger.Oblivious_Trunc(x.v, x.k, x.f, x.kappa)
    elif type(x) is types.sfloat:
        v, p, z, s = floatingpoint.FLRound(x, 0)
        return types.sfloat(v, p, z, s, x.err)
    return x
예제 #3
0
def trunc(x):
    if isinstance(x, types._fix):
        return x.v.right_shift(x.f, x.k, security=x.kappa, signed=True)
    elif type(x) is types.sfloat:
        v, p, z, s = floatingpoint.FLRound(x, 0)
        #return types.sfloat(v, p, z, s, x.err) 
        return types.sfloat(v, p, z, s) 
    return x
예제 #4
0
def trunc(x):
    if type(x) is types.sfix:
        return floatingpoint.Trunc(x.v, x.k - x.f, x.f, x.kappa)
    elif type(x) is types.sfloat:
        return floatingpoint.FLRound(x, 0)
    return x