本文整理汇总了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"));
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例6: RMSTransaction
import org.javarosa.core.util.MathUtils; //导入依赖的package包/类
public RMSTransaction () {
this.tx_id = MathUtils.getRand().nextInt();
this.tx_records = new Hashtable<RMSRec, Integer>();
}
示例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());
}
示例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!
}
示例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);
}
示例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!
}