Java Code Examples for org.luaj.vm2.Varargs#checkdouble()

The following examples show how to use org.luaj.vm2.Varargs#checkdouble() . 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 File: MathLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	if ( x == 0 ) return varargsOf(ZERO,ZERO);
	long bits = Double.doubleToLongBits( x );
	double m = ((bits & (~(-1L<<52))) + (1L<<52)) * ((bits >= 0)? (.5 / (1L<<52)): (-.5 / (1L<<52)));
	double e = (((int) (bits >> 52)) & 0x7ff) - 1022;
	return varargsOf( valueOf(m), valueOf(e) );
}
 
Example 2
Source File: MathLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	if ( x == 0 ) return varargsOf(ZERO,ZERO);
	long bits = Double.doubleToLongBits( x );
	double m = ((bits & (~(-1L<<52))) + (1L<<52)) * ((bits >= 0)? (.5 / (1L<<52)): (-.5 / (1L<<52)));
	double e = (((int) (bits >> 52)) & 0x7ff) - 1022;
	return varargsOf( valueOf(m), valueOf(e) );
}
 
Example 3
Source File: MathLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	if ( x == 0 ) return varargsOf(ZERO,ZERO);
	long bits = Double.doubleToLongBits( x );
	double m = ((bits & (~(-1L<<52))) + (1L<<52)) * ((bits >= 0)? (.5 / (1L<<52)): (-.5 / (1L<<52)));
	double e = (((int) (bits >> 52)) & 0x7ff) - 1022;
	return varargsOf( valueOf(m), valueOf(e) );
}
 
Example 4
Source File: MathLib.java    From luaj with MIT License 5 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	if ( x == 0 ) return varargsOf(ZERO,ZERO);
	long bits = Double.doubleToLongBits( x );
	double m = ((bits & (~(-1L<<52))) + (1L<<52)) * ((bits >= 0)? (.5 / (1L<<52)): (-.5 / (1L<<52)));
	double e = (((int) (bits >> 52)) & 0x7ff) - 1022;
	return varargsOf( valueOf(m), valueOf(e) );
}
 
Example 5
Source File: MathLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double m = args.checkdouble(1);
	for ( int i=2,n=args.narg(); i<=n; ++i )
		m = Math.max(m,args.checkdouble(i));
	return valueOf(m);
}
 
Example 6
Source File: MathLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double m = args.checkdouble(1);
	for ( int i=2,n=args.narg(); i<=n; ++i )
		m = Math.min(m,args.checkdouble(i));
	return valueOf(m);
}
 
Example 7
Source File: MathLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	double intPart = ( x > 0 ) ? Math.floor( x ) : Math.ceil( x );
	double fracPart = x - intPart;
	return varargsOf( valueOf(intPart), valueOf(fracPart) );
}
 
Example 8
Source File: MathLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double m = args.checkdouble(1);
	for ( int i=2,n=args.narg(); i<=n; ++i )
		m = Math.max(m,args.checkdouble(i));
	return valueOf(m);
}
 
Example 9
Source File: MathLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double m = args.checkdouble(1);
	for ( int i=2,n=args.narg(); i<=n; ++i )
		m = Math.min(m,args.checkdouble(i));
	return valueOf(m);
}
 
Example 10
Source File: MathLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	double intPart = ( x > 0 ) ? Math.floor( x ) : Math.ceil( x );
	double fracPart = x - intPart;
	return varargsOf( valueOf(intPart), valueOf(fracPart) );
}
 
Example 11
Source File: MathLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double m = args.checkdouble(1);
	for ( int i=2,n=args.narg(); i<=n; ++i )
		m = Math.max(m,args.checkdouble(i));
	return valueOf(m);
}
 
Example 12
Source File: MathLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double m = args.checkdouble(1);
	for ( int i=2,n=args.narg(); i<=n; ++i )
		m = Math.min(m,args.checkdouble(i));
	return valueOf(m);
}
 
Example 13
Source File: MathLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public Varargs invoke(Varargs args) {
	double x = args.checkdouble(1);
	double intPart = ( x > 0 ) ? Math.floor( x ) : Math.ceil( x );
	double fracPart = x - intPart;
	return varargsOf( valueOf(intPart), valueOf(fracPart) );
}