Here you can find the source of isInRange(BigInteger in, int range, double eps)
Parameter | Description |
---|---|
in | The BigInteger to test |
range | the bit-range specifier |
eps | an epsilon that's applied on the positive interval |
public static final boolean isInRange(BigInteger in, int range, double eps)
//package com.java2s; /*/* w w w .ja va2s. c om*/ * This file is part of an unofficial ISO20008-2.2 sample implementation to * evaluate certain schemes for their applicability on Android-based mobile * devices. The source is licensed under the modified 3-clause BSD license, * see the readme. * * The code was published in conjunction with the publication called * "Group Signatures on Mobile Devices: Practical Experiences" by * Potzmader, Winter, Hein, Hanser, Teufl and Chen */ import java.math.BigInteger; public class Main { /** * Tests whether a given {@link BigInteger} is in the following range: * [-2^range, 2^(eps * range)-1] (inclusive). * * @param in The {@link BigInteger} to test * @param range the bit-range specifier * @param eps an epsilon that's applied on the positive interval * @return true if it is in between the given range (inclusive), * false otherwise */ public static final boolean isInRange(BigInteger in, int range, double eps) { if (((in.signum() > 0) && (in.bitLength() > (int) (eps * range)) && (in.compareTo(BigInteger.valueOf(1).shiftLeft(range)) > 0)) || ((in.signum() < 0) && (in.bitLength() > range) && (in.compareTo(BigInteger.valueOf(-1).shiftLeft(range)) < 0))) return false; return true; } }