|
SecreC 2 language
2.8.0 (2023.09)
Language and standard library reference
|
Operators within the SecreC language
Table 1: Operator precedence from highest to lowest
| Level | Operator | Description | Associativity |
|---|---|---|---|
| 14 | =,+=,-=,*=,/=,%=,&=,|=,^= | Assignment operators | Right |
| 13 | ?: | Ternary operator | Left |
| 12 | || | Logical disjunction | Left |
| 11 | && | Logical conjunction | Left |
| 10 | | | Bitwise OR | Left |
| 9 | ^ | Bitwise XOR | Left |
| 8 | & | Bitwise AND | Left |
| 7 | ==,!= | Relational operators | - |
| 6 | <,>,<=,>= | - | |
| 5 | <<,>> | Bitshift operators | Left |
| 4 | +,- | Arithmetic operators | Left |
| 3 | *,/,% | Left | |
| 2 | ++ | Increment operator | - |
| 1 | -- | Decrement operator | - |
| 0 | ~,!,- | Unary bitwise/logical inverse and negation | Right |
[] | Array access | ||
() | Function call |
Supported types: bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64
| type | operators |
|---|---|
| bool | > , < , >= , <= , == , !=, &&, ||, &, |, ^, ! |
| uint8: | + , - , * , / , % , > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| uint16: | + , - , * , / , % , > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| uint32: | + , - , * , / , % , > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| uint64: | + , - , * , / , % , > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| int8: | + , - , * , / , % , > , < , >= , <= , == , != |
| int16: | + , - , * , / , % , > , < , >= , <= , == , != |
| int32: | + , - , * , / , % , > , < , >= , <= , == , != |
| int64: | + , - , * , / , % , > , < , >= , <= , == , != |
| float32: | + , - , * , / , % , > , < , >= , <= , == , != |
| float64: | + , - , * , / , % , > , < , >= , <= , == , != |
| type | castings |
|---|---|
| bool | uint8/16/32/64 , int8/16/32/64 , float32/64 |
| uint8: | bool , uint16/32/64 , int8/16/32/64 , float32/64 |
| uint16: | bool , uint8/32/64 , int8/16/32/64 , float32/64 |
| uint32: | bool , uint8/16/64 , int8/16/32/64 , float32/64 |
| uint64: | bool , int8/16/32 , int8/16/32/64 , float32/64 |
| int8: | bool , int16/32/64 , uint8/16/32/64 , float32/64 |
| int16: | bool , int8/32/64 , uint8/16/32/64 , float32/64 |
| int32: | bool , int8/16/64 , uint8/16/32/64 , float32/64 |
| int64: | bool , int8/16/32 , uint8/16/32/64 , float32/64 |
| float32: | bool , uint8/16/32/64 , int8/16/32/64 , float64 |
| float64: | bool , uint8/16/32/64 , int8/16/32/64 , float32 |
Supported types: bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64
| type | operators |
|---|---|
| bool | == , !=, &, |, ^, ! |
| uint8: | + , - , * , / , % , > , < , >= , <= , == , !=, <<, >> |
| uint16: | + , - , * , / , % , > , < , >= , <= , == , !=, <<, >> |
| uint32: | + , - , * , / , % , > , < , >= , <= , == , !=, <<, >> |
| uint64: | + , - , * , / , % , > , < , >= , <= , == , !=, <<, >> |
| int8: | + , - , * , > , < , >= , <= , == , != |
| int16: | + , - , * , > , < , >= , <= , == , != |
| int32: | + , - , * , > , < , >= , <= , == , != |
| int64: | + , - , * , > , < , >= , <= , == , != |
| float32: | + , - , * , / , > , < , >= , <= , == , != |
| float64: | + , - , * , / , > , < , >= , <= , == , != |
| xor_uint8: | > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| xor_uint16: | > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| xor_uint32: | > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| xor_uint64: | > , < , >= , <= , == , !=, &, |, ^, ~, <<, >> |
| type | castings |
|---|---|
| bool | uint8/16/32/64 , int8/16/32/64 , float32/64 , xor_uint8/16/32/64 |
| uint8: | bool , uint16/32/64 , int8, float32/64 |
| uint16: | bool , uint8/32/64 , int16, float32/64 |
| uint32: | bool , uint8/16/64 , int32, float32/64 |
| uint64: | bool , uint8/16/32 , int64 |
| int8: | bool , uint8, float32/64 |
| int16: | bool , uint16, float32/64 |
| int32: | bool , uint32, float32/64 |
| int64: | bool , uint64 |
| float32: | float64 |
| float64: | float32 |
| xor_uint8: | xor_uint16, xor_uint32, xor_uint64 |
| xor_uint16: | xor_uint8, xor_uint32, xor_uint64 |
| xor_uint32: | xor_uint8, xor_uint16, xor_uint64 |
| xor_uint64: | xor_uint8, xor_uint16, xor_uint32 |