Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions website/cue/reference/remap/expressions/bitwise.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package metadata

remap: expressions: bitwise: {
title: "Bitwise"
description: """
A _bitwise_ expression performs an operation directly on the individual bits of integer operands.
"""
return: """
Returns the result of the expression as defined by the operator.
"""

grammar: {
source: """
expression ~ operator ~ expression
"""
definitions: {
expression: {
description: """
The `expression` can be any expression that returns an integer.
"""
}
operator: {
description: """
The `operator` defines the operation performed on the left-hand-side and right-hand-side operands.
"""
enum: {
"&": "Bitwise AND. Operates on `int` type."
"^": "Bitwise OR. Operates on `int` type."
"~": "Bitwise NOT. Operates on `int` type."
}
}
}
}

examples: [
{
title: "AND"
source: #"""
1 & 5
"""#
return: 1
},
{
title: "OR"
source: #"""
1 ^ 4
"""#
return: 5
},
{
title: "NOT"
source: #"""
~5
"""#
return: -6
}
]
}
Loading