private int toKiloBytes(long bytes) { return (int)Math.rint(bytes / (double)1024); } }
@Override public double apply(double a) { return Math.rint(a); } };
@Override public double apply(double a) { return Math.rint(a / precision) * precision; } };
public int getComplexityAverage() { return (double) methodCount == 0 ? 1 : (int) Math.rint((double) decisionPoints / (double) methodCount); } }
public int getComplexityAverage() { return (double) methodCount == 0 ? 1 : (int) Math.rint((double) decisionPoints / (double) methodCount); } }
public int getComplexityAverage() { return (double) methodCount == 0 ? 1 : (int) Math.rint((double) decisionPoints / (double) methodCount); } }
public static int pointsToPixel(double points) { points *= PIXEL_DPI; points /= POINT_DPI; return (int)Math.rint(points); }
/** * Converts points to EMUs * @param points points * @return EMUs */ public static int toEMU(double points){ return (int)Math.rint(EMU_PER_POINT*points); }
public static int pointsToMaster(double points) { points *= MASTER_DPI; points /= POINT_DPI; return (int)Math.rint(points); }
/** * Convert sRGB float component [0..1] from sRGB to linear RGB [0..100000] * * @see Color#getRGBColorComponents(float[]) */ public static int srgb2lin(float sRGB) { // scRGB has a linear gamma of 1.0, scale the AWT-Color which is in sRGB to linear RGB // see https://en.wikipedia.org/wiki/SRGB (the reverse transformation) if (sRGB <= 0.04045d) { return (int)Math.rint(100000d * sRGB / 12.92d); } else { return (int)Math.rint(100000d * Math.pow((sRGB + 0.055d) / 1.055d, 2.4d)); } }
/** * @return true, if this is an integer color value */ private static boolean isInt(float f) { return Math.abs((f*255d) - Math.rint(f*255d)) < 0.00001; }
/** * 间隔时间在左右1s的范围内随机 * * @param interval * @return */ private int randomInterval(int interval) { int min = interval - 1000; if(min < 1) { min = 1; } int max = interval + 1000; return (int)Math.rint(Math.random()*(max-min)+min); }
@Override protected ExprEval eval(double param) { return ExprEval.of(Math.rint(param)); } }
public static double rint(RValue x) throws EvaluationException { return Math.rint(x.getValue()); }
@Override public double nextDouble() { return Math.rint(gen.nextDouble() * 10) / 10.0; } };
/** * Returns a new transform from the given transformation matrix, if the * resulting transform would be discrete. * * @param matrix The matrix to use for the transform * @return The new transform, or {@link Optional#empty()} */ public static Optional<DiscreteTransform2> of(Matrix3d matrix) { if (Arrays.stream(matrix.toArray()) .anyMatch(value -> Math.rint(value) != value)) { return Optional.empty(); } return Optional.of(new DiscreteTransform2(matrix)); }
protected List<AsyncLoopThread> setSerializeThreads() { WorkerTopologyContext workerTopologyContext = contextMaker.makeWorkerTopologyContext(sysTopology); int tasksNum = shutdownTasks.size(); double workerRatio = ConfigExtension.getWorkerSerializeThreadRatio(stormConf); int workerSerialThreadNum = Utils.getInt(Math.ceil(workerRatio * tasksNum)); if (workerSerialThreadNum > 0 && tasksNum > 0) { double average = tasksNum / (double) workerSerialThreadNum; for (int i = 0; i < workerSerialThreadNum; i++) { int startRunTaskIndex = Utils.getInt(Math.rint(average * i)); serializeThreads.add(new AsyncLoopThread(new WorkerSerializeRunnable( shutdownTasks, stormConf, workerTopologyContext, startRunTaskIndex, i))); } } return serializeThreads; }
protected List<AsyncLoopThread> setDeserializeThreads() { WorkerTopologyContext workerTopologyContext = contextMaker.makeWorkerTopologyContext(sysTopology); int tasksNum = shutdownTasks.size(); double workerRatio = ConfigExtension.getWorkerDeserializeThreadRatio(stormConf); int workerDeserThreadNum = Utils.getInt(Math.ceil(workerRatio * tasksNum)); if (workerDeserThreadNum > 0 && tasksNum > 0) { double average = tasksNum / (double) workerDeserThreadNum; for (int i = 0; i < workerDeserThreadNum; i++) { int startRunTaskIndex = Utils.getInt(Math.rint(average * i)); deserializeThreads.add(new AsyncLoopThread(new WorkerDeserializeRunnable( shutdownTasks, stormConf, workerTopologyContext, startRunTaskIndex, i))); } } return deserializeThreads; }