Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Syntax for bitwise AND operator
Syntax for bitwise AND operator [message #1793116] Tue, 31 July 2018 06:52 Go to next message
Eclipse UserFriend
Hi ,

I have an if condition in which i want to test all the condition and if all are TRUE then enter the condition.

but in xtend i dont know the syntax of bitwise or as in java it is '&'


Regards,
Shubhankar
Re: Syntax for bitwise AND operator [message #1793117 is a reply to message #1793116] Tue, 31 July 2018 06:55 Go to previous messageGo to next message
Eclipse UserFriend
you can use

1.bitwiseOr(2)
1.bitwiseAnd(2)
Re: Syntax for bitwise AND operator [message #1793122 is a reply to message #1793117] Tue, 31 July 2018 07:18 Go to previous messageGo to next message
Eclipse UserFriend
both my condition are boolean condition. when i try to implement

(booleanValue1).bitwiseAnd(booleanVlaue2), I am geting the error as:
The method bitwiseAnd(boolean) is undefined for the type boolean

Do I need to import any package?

[Updated on: Tue, 31 July 2018 07:26] by Moderator

Re: Syntax for bitwise AND operator [message #1793129 is a reply to message #1793122] Tue, 31 July 2018 08:25 Go to previous messageGo to next message
Eclipse UserFriend
bytewise and for java ???
what exactly should that do different from a normal &&

[Updated on: Tue, 31 July 2018 08:25] by Moderator

Re: Syntax for bitwise AND operator [message #1793130 is a reply to message #1793129] Tue, 31 July 2018 08:31 Go to previous messageGo to next message
Eclipse UserFriend
of course you can do something like

java util
package a;

import org.eclipse.xtext.xbase.lib.Inline;
import org.eclipse.xtext.xbase.lib.Pure;

public class Lala {
	
	@Pure
	@Inline(value="($1 & $2)", constantExpression=true)
	public static boolean bytewiseAnd(boolean a, boolean b) {
		return a&b;
	}
	
	@Pure
	@Inline(value="($1 | $2)", constantExpression=true)
	public static boolean bytewiseOr(boolean a, boolean b) {
		return a|b;
	}

}

xtend code
package a

import static extension a.Lala.*

class Demo { 
	def main() {
		val x = 1.bitwiseOr(2)
		val y = 1.bitwiseAnd(2)
		val a = true.bytewiseAnd(false)
		val a2 = true.bytewiseOr(false) 
	}
}
Re: Syntax for bitwise AND operator [message #1794935 is a reply to message #1793129] Tue, 11 September 2018 06:16 Go to previous message
Eclipse UserFriend
Christian Dietrich wrote on Tue, 31 July 2018 12:25
bytewise and for java ???
what exactly should that do different from a normal &&


& and | as boolean operators are eager as opposed to && and || which are lazy.
Previous Topic:XText importing a specific file extension
Next Topic:Operator == with null operand
Goto Forum:
  


Current Time: Tue Jun 24 16:08:10 EDT 2025

Powered by FUDForum. Page generated in 0.30463 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top