Java Code Examples for org.luaj.vm2.lib.MathLib

The following examples show how to use org.luaj.vm2.lib.MathLib. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: luaj   Author: luaj   File: JmePlatform.java    License: MIT License 6 votes vote down vote up
/**
 * Create a standard set of globals for JME including all the libraries.
 * 
 * @return Table of globals initialized with the standard JME libraries
 * @see #debugGlobals()
 * @see org.luaj.vm2.lib.jse.JsePlatform
 * @see org.luaj.vm2.lib.jme.JmePlatform
 */
public static Globals standardGlobals() {
	Globals globals = new Globals();
	globals.load(new BaseLib());
	globals.load(new PackageLib());
	globals.load(new Bit32Lib());
	globals.load(new OsLib());
	globals.load(new MathLib());
	globals.load(new TableLib());
	globals.load(new StringLib());
	globals.load(new CoroutineLib());
	globals.load(new JmeIoLib());
	LoadState.install(globals);
	LuaC.install(globals);
	return globals;		
}
 
Example #2
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaString.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue pow(double rhs) {
    return MathLib.dpow(checkarith(), rhs);
}
 
Example #3
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaString.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue pow(int rhs) {
    return MathLib.dpow(checkarith(), rhs);
}
 
Example #4
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaString.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue powWith(double lhs) {
    return MathLib.dpow(lhs, checkarith());
}
 
Example #5
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaString.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue powWith(int lhs) {
    return MathLib.dpow(lhs, checkarith());
}
 
Example #6
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaDouble.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue pow(double rhs) {
    return MathLib.dpow(v, rhs);
}
 
Example #7
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaDouble.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue pow(int rhs) {
    return MathLib.dpow(v, rhs);
}
 
Example #8
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaDouble.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue powWith(double lhs) {
    return MathLib.dpow(lhs, v);
}
 
Example #9
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaDouble.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LuaValue powWith(int lhs) {
    return MathLib.dpow(lhs, v);
}
 
Example #10
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LexState.java    License: GNU General Public License v3.0 4 votes vote down vote up
LuaValue strx2number(String str, SemInfo seminfo) {
    char[] c = str.toCharArray();
    int s = 0;
    while (s < c.length && isspace(c[s]))
        ++s;
    // Check for negative sign
    double sgn = 1.0;
    if (s < c.length && c[s] == '-') {
        sgn = -1.0;
        ++s;
    }
    /* Check for "0x" */
    if (s + 2 >= c.length)
        return LuaValue.ZERO;
    if (c[s++] != '0')
        return LuaValue.ZERO;
    if (c[s] != 'x' && c[s] != 'X')
        return LuaValue.ZERO;
    ++s;

    // read integer part.
    double m = 0;
    int e = 0;
    while (s < c.length && isxdigit(c[s]))
        m = (m * 16) + hexvalue(c[s++]);
    if (s < c.length && c[s] == '.') {
        ++s;  // skip dot
        while (s < c.length && isxdigit(c[s])) {
            m = (m * 16) + hexvalue(c[s++]);
            e -= 4;  // Each fractional part shifts right by 2^4
        }
    }
    if (s < c.length && (c[s] == 'p' || c[s] == 'P')) {
        ++s;
        int exp1 = 0;
        boolean neg1 = false;
        if (s < c.length && c[s] == '-') {
            neg1 = true;
            ++s;
        }
        while (s < c.length && isdigit(c[s]))
            exp1 = exp1 * 10 + c[s++] - '0';
        if (neg1)
            exp1 = -exp1;
        e += exp1;
    }
    return LuaValue.valueOf(sgn * m * MathLib.dpow_d(2.0, e));
}
 
Example #11
Source Project: XPrivacyLua   Author: M66B   File: LexState.java    License: GNU General Public License v3.0 4 votes vote down vote up
LuaValue strx2number(String str, SemInfo seminfo) {
	char[] c = str.toCharArray();
	int s = 0;
	while ( s < c.length && isspace(c[s]))
		++s;
	// Check for negative sign
	double sgn = 1.0;
	if (s < c.length && c[s] == '-') {
		sgn = -1.0;
		++s;
	}
	/* Check for "0x" */
	if (s + 2 >= c.length )
		return LuaValue.ZERO;
	if (c[s++] != '0')
		return LuaValue.ZERO;
	if (c[s] != 'x' && c[s] != 'X')
		return LuaValue.ZERO;
	++s;

	// read integer part.
	double m = 0;
	int e = 0;
	while (s < c.length && isxdigit(c[s]))
		m = (m * 16) + hexvalue(c[s++]);
	if (s < c.length && c[s] == '.') {
		++s;  // skip dot
		while (s < c.length && isxdigit(c[s])) {
			m = (m * 16) + hexvalue(c[s++]);
			e -= 4;  // Each fractional part shifts right by 2^4
		}
	}
	if (s < c.length && (c[s] == 'p' || c[s] == 'P')) {
		++s;
		int exp1 = 0;
		boolean neg1 = false;
		if (s < c.length && c[s] == '-') {
			neg1 = true;
			++s;
		}
		while (s < c.length && isdigit(c[s]))
			exp1 = exp1 * 10 + c[s++] - '0';
		if (neg1)
			exp1 = -exp1;
		e += exp1;
	}
	return LuaValue.valueOf(sgn * m * MathLib.dpow_d(2.0, e));
}
 
Example #12
Source Project: HtmlNative   Author: hsllany   File: LexState.java    License: Apache License 2.0 4 votes vote down vote up
LuaValue strx2number(String str, SemInfo seminfo) {
	char[] c = str.toCharArray();
	int s = 0;
	while ( s < c.length && isspace(c[s]))
		++s;
	// Check for negative sign
	double sgn = 1.0;
	if (s < c.length && c[s] == '-') {
		sgn = -1.0;
		++s;
	}
	/* Check for "0x" */
	if (s + 2 >= c.length )
		return LuaValue.ZERO;
	if (c[s++] != '0')
		return LuaValue.ZERO;
	if (c[s] != 'x' && c[s] != 'X')
		return LuaValue.ZERO;
	++s;

	// read integer part.
	double m = 0;
	int e = 0;
	while (s < c.length && isxdigit(c[s]))
		m = (m * 16) + hexvalue(c[s++]);
	if (s < c.length && c[s] == '.') {
		++s;  // skip dot
		while (s < c.length && isxdigit(c[s])) {
			m = (m * 16) + hexvalue(c[s++]);
			e -= 4;  // Each fractional part shifts right by 2^4
		}
	}
	if (s < c.length && (c[s] == 'p' || c[s] == 'P')) {
		++s;
		int exp1 = 0;
		boolean neg1 = false;
		if (s < c.length && c[s] == '-') {
			neg1 = true;
			++s;
		}
		while (s < c.length && isdigit(c[s]))
			exp1 = exp1 * 10 + c[s++] - '0';
		if (neg1)
			exp1 = -exp1;
		e += exp1;
	}
	return LuaValue.valueOf(sgn * m * MathLib.dpow_d(2.0, e));
}
 
Example #13
Source Project: luaj   Author: luaj   File: LexState.java    License: MIT License 4 votes vote down vote up
LuaValue strx2number(String str, SemInfo seminfo) {
	char[] c = str.toCharArray();
	int s = 0;
	while ( s < c.length && isspace(c[s]))
		++s;
	// Check for negative sign
	double sgn = 1.0;
	if (s < c.length && c[s] == '-') {
		sgn = -1.0;
		++s;
	}
	/* Check for "0x" */
	if (s + 2 >= c.length )
		return LuaValue.ZERO;
	if (c[s++] != '0')
		return LuaValue.ZERO;
	if (c[s] != 'x' && c[s] != 'X')
		return LuaValue.ZERO;
	++s;

	// read integer part.
	double m = 0;
	int e = 0;
	while (s < c.length && isxdigit(c[s]))
		m = (m * 16) + hexvalue(c[s++]);
	if (s < c.length && c[s] == '.') {
		++s;  // skip dot
		while (s < c.length && isxdigit(c[s])) {
			m = (m * 16) + hexvalue(c[s++]);
			e -= 4;  // Each fractional part shifts right by 2^4
		}
	}
	if (s < c.length && (c[s] == 'p' || c[s] == 'P')) {
		++s;
		int exp1 = 0;
		boolean neg1 = false;
		if (s < c.length && c[s] == '-') {
			neg1 = true;
			++s;
		}
		while (s < c.length && isdigit(c[s]))
			exp1 = exp1 * 10 + c[s++] - '0';
		if (neg1)
			exp1 = -exp1;
		e += exp1;
	}
	return LuaValue.valueOf(sgn * m * MathLib.dpow_d(2.0, e));
}
 
Example #14
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue pow(double rhs )        { return MathLib.dpow(v,rhs); } 
Example #15
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue pow(int rhs )        { return MathLib.dpow(v,rhs); } 
Example #16
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue powWith(double lhs )   { return MathLib.dpow(lhs,v); } 
Example #17
Source Project: VideoOS-Android-SDK   Author: VideoOS   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue powWith(int lhs )      { return MathLib.dpow(lhs,v); } 
Example #18
Source Project: XPrivacyLua   Author: M66B   File: LuaString.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   pow( double rhs )        { return MathLib.dpow(checkarith(),rhs); } 
Example #19
Source Project: XPrivacyLua   Author: M66B   File: LuaString.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   pow( int rhs )           { return MathLib.dpow(checkarith(),rhs); } 
Example #20
Source Project: XPrivacyLua   Author: M66B   File: LuaString.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   powWith( double lhs )    { return MathLib.dpow(lhs, checkarith()); } 
Example #21
Source Project: XPrivacyLua   Author: M66B   File: LuaString.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   powWith( int lhs )       { return MathLib.dpow(lhs, checkarith()); } 
Example #22
Source Project: XPrivacyLua   Author: M66B   File: LuaDouble.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   pow( double rhs )        { return MathLib.dpow(v,rhs); } 
Example #23
Source Project: XPrivacyLua   Author: M66B   File: LuaDouble.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   pow( int rhs )        { return MathLib.dpow(v,rhs); } 
Example #24
Source Project: XPrivacyLua   Author: M66B   File: LuaDouble.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   powWith( double lhs )   { return MathLib.dpow(lhs,v); } 
Example #25
Source Project: XPrivacyLua   Author: M66B   File: LuaDouble.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   powWith( int lhs )      { return MathLib.dpow(lhs,v); } 
Example #26
Source Project: XPrivacyLua   Author: M66B   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   pow( double rhs )        { return MathLib.dpow(v,rhs); } 
Example #27
Source Project: XPrivacyLua   Author: M66B   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   pow( int rhs )        { return MathLib.dpow(v,rhs); } 
Example #28
Source Project: XPrivacyLua   Author: M66B   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   powWith( double lhs )   { return MathLib.dpow(lhs,v); } 
Example #29
Source Project: XPrivacyLua   Author: M66B   File: LuaInteger.java    License: GNU General Public License v3.0 votes vote down vote up
public LuaValue   powWith( int lhs )      { return MathLib.dpow(lhs,v); } 
Example #30
Source Project: HtmlNative   Author: hsllany   File: LuaString.java    License: Apache License 2.0 votes vote down vote up
public LuaValue   pow( double rhs )        { return MathLib.dpow(checkarith(),rhs); }