当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils类代码示例

本文整理汇总了Java中org.javarosa.core.util.MathUtils的典型用法代码示例。如果您正苦于以下问题:Java MathUtils类的具体用法?Java MathUtils怎么用?Java MathUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MathUtils类属于org.javarosa.core.util包,在下文中一共展示了MathUtils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClientNonce

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
private String getClientNonce() {
    if(!parameters.contains("cnonce")) {
        Random r = MathUtils.getRand();
        byte[] b = new byte[8];
        for(int i = 0; i < b.length ; ++i) {
            b[i] = (byte)r.nextInt(256);
        }

        String cnonce = MD5.toHex(b);
        parameters.put("cnonce",AuthUtils.quote(cnonce));
        return cnonce;
    } else {
        return AuthUtils.unquote(parameters.get("cnonce"));
    }

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:DigestAuthResponse.java

示例2: subsetArgList

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * return a subset of an argument list as a new arguments list
 *
 * @param args
 * @param start index to start at
 * @param skip sub-list will contain every nth argument, where n == skip (default: 1)
 * @return
 */
private static Object[] subsetArgList (Object[] args, int start, int skip) {
	if (start > args.length || skip < 1) {
		throw new RuntimeException("error in subsetting arglist");
	}

	Object[] subargs = new Object[(int)MathUtils.divLongNotSuck(args.length - start - 1, skip) + 1];
	for (int i = start, j = 0; i < args.length; i += skip, j++) {
		subargs[j] = args[i];
	}

	return subargs;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:21,代码来源:XPathFuncExpr.java

示例3: subsetArgList

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * return a subset of an argument list as a new arguments list
 *
 * @param start index to start at
 * @param skip  sub-list will contain every nth argument, where n == skip (default: 1)
 */
private static Object[] subsetArgList(Object[] args, int start, int skip) {
    if (start > args.length || skip < 1) {
        throw new RuntimeException("error in subsetting arglist");
    }

    Object[] subargs = new Object[(int)MathUtils.divLongNotSuck(args.length - start - 1, skip) + 1];
    for (int i = start, j = 0; i < args.length; i += skip, j++) {
        subargs[j] = args[i];
    }

    return subargs;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:19,代码来源:XPathFuncExpr.java

示例4: testAsinsBehaveSimilarly

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * Test that standard and J2ME asins behave similarly.
 * More extensive tests are unnecessary because the code was adapted from
 * http://www.netlib.org/fdlibm/e_asin.c, as cited in the function comments.
 */
@Test
public void testAsinsBehaveSimilarly() {
    double tolerance = 0.00000001;
    double standardAsin1 = Math.asin(1);
    double j2meAsin1 = MathUtils.asin(1);
    Assert.assertTrue("Math.asin(1) = " + standardAsin1
            + ", while MathUtils.asin(1) = " + j2meAsin1,
            Math.abs(standardAsin1 - j2meAsin1) < tolerance);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:15,代码来源:MathUtilsTest.java

示例5: subsetArgList

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * return a subset of an argument list as a new arguments list
 *
 * @param start index to start at
 * @param skip  sub-list will contain every nth argument, where n == skip (default: 1)
 */
protected static Object[] subsetArgList(Object[] args, int start, int skip) {
    if (start > args.length || skip < 1) {
        throw new RuntimeException("error in subsetting arglist");
    }

    Object[] subargs = new Object[(int)MathUtils.divLongNotSuck(args.length - start - 1, skip) + 1];
    for (int i = start, j = 0; i < args.length; i += skip, j++) {
        subargs[j] = args[i];
    }

    return subargs;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:19,代码来源:FunctionUtils.java

示例6: RMSTransaction

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
public RMSTransaction () {
    this.tx_id = MathUtils.getRand().nextInt();
    this.tx_records = new Hashtable<RMSRec, Integer>();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:5,代码来源:RMSTransaction.java

示例7: evalBody

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
@Override
public Object evalBody(DataInstance model, EvaluationContext evalContext, Object[] evaluatedArgs) {
    //calculated expressions may be recomputed w/o warning! use with caution!!
    return new Double(MathUtils.getRand().nextDouble());
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:6,代码来源:XPathRandomFunc.java

示例8: dateDiff

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * return the number of days between a and b, positive if b is later than a
 *
 * @param a
 * @param b
 * @return # days difference
 */
public static int dateDiff (Date a, Date b) {
	return (int)MathUtils.divLongNotSuck(roundDate(b).getTime() - roundDate(a).getTime() + DAY_IN_MS / 2, DAY_IN_MS);
	//half-day offset is needed to handle differing DST offsets!
}
 
开发者ID:medic,项目名称:javarosa,代码行数:12,代码来源:DateUtils.java

示例9: daysSinceEpoch

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * @param date the date object to be analyzed
 * @return The number of days (as a double precision floating point) since the Epoch
 */
public static int daysSinceEpoch(Date date) {
    return (int)MathUtils.divLongNotSuck(roundDate(date).getTime() - EPOCH_TIME + DAY_IN_MS / 2, DAY_IN_MS);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:8,代码来源:DateUtils.java

示例10: dateDiff

import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
/**
 * return the number of days between a and b, positive if b is later than a
 *
 * @return # days difference
 */
public static int dateDiff(Date a, Date b) {
    return (int)MathUtils.divLongNotSuck(roundDate(b).getTime() - roundDate(a).getTime() + DAY_IN_MS / 2, DAY_IN_MS);
    //half-day offset is needed to handle differing DST offsets!
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:DateUtils.java


注:本文中的org.javarosa.core.util.MathUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。