WinHoldEm Help - C Tutorial

Home Help Download Support My license License agreement Pricing System requirements Notices



Syntax Operators Constants Boolean-Logic

Introduction

WinHoldEm formulas are very similar to the C programming expression syntax. If you already know and understand C programming expressions then this tutorial may serve as a convenient reference. If you are a beginner to the C programming syntax then we hope you find this primer useful.

Everything described here is standard ANSI C except where specifically noted otherwise.

Syntax

The general syntax for WinHoldem formulas is same as that of the C programming language. For the C programmers out there, you should feel right at home. For the uninitiated it will seem cryptic at first, but you know you've always wanted to learn C. Here's your chance. Welcome to the club.

The formulas are strict R-VALUES (right side of an assignment expression). There is no assignment operator. All values are stored as (double) floating point values on the expression stack. For bitwise operations the values are first converted to (int) and then the operator is applied.

WinHoldem Formula Operators

Operator Precedence
categoryoperatorassociativity
Exponentiation* ** ln Right to Left
Unary ! ~ - ` Right to Left
Multiplicative * / % Left to Right
Additive + - Left to Right
Bitwise Shift << >> Left to Right
Relational < > <= >= Left to Right
Equality == != Left to Right
Bitwise AND & Left to Right
Bitwise XOR ^ Left to Right
Bitwise OR | Left to Right
Logical AND && Left to Right
Logical XOR* ^^ Left to Right
Logical OR || Left to Right
Conditional ?: Right to Left
Group * () [] {} Left to Right
* not standard ANSI C

Boolean Logic

A boolean expression is composed of LOGICAL OPERATORS and OPERANDS. All boolean operands have only two values - true false. Each LOGICAL OPERAND has a very well defined operation upon the OPERAND(S) in the expression, with a very well defined result.

True False

When any numeric value is used in conjunction with a LOGICAL operator
any zero values are considered to be false (0)
any non-zero values are considered to be true (1)

Put very simply, if the numeric value in question is not zero
then it is considered to be true for boolean purposes.

Numeric Boolean
Values
Numeric
Value
Boolean
Value
0false
1true
othertrue

Logical Operators
Operator
Name
Operator
Token
NOT!
AND&&
OR||
XOR^^

Unary

A unary operator takes a single operand.
Natural Log ln
Logical NOT !
Bitwise NOT ~
Unary Minus -
Bit Count `

Unary Minus -

A good example is the minus sign when it is used to alter the sign of a value.
Example: a + b / -4
The minus sign in front of the 4 is a unary minus.

Bit Count ` (not ANSI-C)

BIT COUNT 32-bit example
a `a
00000000000000000000000000000000
00000000000001000000000000000001
00000100000001000000000000100003
111111111111111111111111111111132

Eponentiation

Power ** (not ANSI-C)

a ** b
Standard algebraic exponentiation on a and b.
a is raised to the power of b.

Natural Log ln (not ANSI-C)

ln a
Standard algebraic natural log of a
a == e ** (ln a)

Natural Log Base e (not ANSI-C)

e == ln(1)
e == 2.71828182845905

Multiplicative

Multiply *

a * b
Standard algebraic multiplication on a and b.

Divide /

a / b
Standard algebraic division on a and b.

Modulo %

a % b
Standard algebraic modulo on a and b.

Additive

Add +

a + b
Standard algebraic addition on a and b.

Subtract -

a - b
Standard algebraic subtraction on a and b.

BITWISE

BITWISE NOT ~

a LOGICAL NOT operation on a bit by bit basis
BITWISE NOT 32-bit example
expressionbinary
a 11001001011101010110010101111010
~a 00110110100010101001101010000101

BITWISE AND &

a LOGICAL AND operation on a bit by bit basis
BITWISE AND 32-bit example
expressionbinary
a 11001001011101010110010101111010
b 01001010010100101110001010101111
a&b01001000010100000110000000101010

BITWISE OR |

a LOGICAL OR operation on a bit by bit basis
BITWISE OR 32-bit example
expressionbinary
a 11001001011101010110010101111010
b 01001010010100101110001010101111
a|b11001011011101111110011111111111

BITWISE XOR ^

a LOGICAL XOR operation on a bit by bit basis
BITWISE XOR 32-bit example
expressionbinary
a 11001001011101010110010101111010
b 01001010010100101110001010101111
a^b10000011001001111000011111010101

BITWISE SHIFT

BITWISE SHIFTLEFT <<

Slide the entire bit pattern to the left by N
BITWISE SHIFTLEFT 32-bit example
expressionbinary
a 11001001011101010110010101111010
a<<1 10010010111010101100101011110100
a<<7 10111010101100101011110100000000
a<<3100000000000000000000000000000000
a<<3211001001011101010110010101111010
Note that the leftmost bits are simply dropped.
Note that the rightmost bits are filled with incoming 0's. Note that shift magnitude is used as modulo 32.

BITWISE SHIFTRIGHT >>

Slide the entire bit pattern to the right by N
BITWISE SHIFTRIGHT 32-bit example
expressionbinary
a 11001001011101010110010101111010
a>>1 11100100101110101011001010111101
a>>7 11111111100100101110101011001010
a>>3111111111111111111111111111111111
a>>3211001001011101010110010101111010
Note that the rightmost bits are simply dropped.
Note that the leftmost bits are filled with the leftmost bit of the operand.
Note that shift magnitude is used as modulo 32.
BITWISE SHIFTRIGHT 32-bit example
expressionbinary
a 01001001011101010110010101111010
a>>1 00100100101110101011001010111101
a>>7 00000000100100101110101011001010
a>>3100000000000000000000000000000000
a>>3201001001011101010110010101111010

LOGICAL

LOGICAL NOT !

false when the operand is true
true when the operand is false

LOGICAL NOT
a!a
falsetrue
truefalse
01
Note that the default unambiguous numeric value for true is 1.

LOGICAL AND &&

false when any operand is false
true when both operands are true

LOGICAL AND
aba && b
falsefalsefalse
falsetruefalse
truefalsefalse
truetruetrue

LOGICAL OR ||

false when both operands are false
true when any operand is true

LOGICAL OR
aba || b
falsefalsefalse
falsetruetrue
truefalsetrue
truetruetrue

LOGICAL XOR ^^ (not ANSI-C)

false when operands are boolean equal
true when operands are not boolean equal

LOGICAL XOR
aba ^^ b
falsefalsefalse
falsetruetrue
truefalsetrue
truetruefalse

Note that a^^b is equivalent to (a!=0)^(b!=0)

Relational

Less Than <

LESS THAN
aba < b
-10true
 00false
+10false

Greater Than >

GREATER THAN
aba > b
-10false
 00false
+10true

Less Than or Equal <=

LESS THAN OR EQUAL
aba <= b
-10true
 00true
+10false

Greater Than or Equal >=

GREATER THAN OR EQUAL
aba >= b
-10false
 00true
+10true

Equality

Equal ==

EQUAL
aba == b
-10false
 00true
+10false

Not Equal !=

NOT EQUAL
aba != b
-10true
 00false
+10true

Conditional ?:

a ? b : c
Standard algorithmic if then else
If a then b else c

CONDITIONAL
abca ? b : c
trueanyanyb
falseanyanyc

WinHoldEm Exclusive Group Operators []{} (not ANSI-C)

Note that WinHoldEm uses the []{} operators differently than ANSI C. Brackets [] and Braces {} are used by WinHoldEm as exlusive group operators. The exclusive group operators cannot be nested. They must be closed before starting another group of the same type. The following example is allowable syntax:
{ [ a * (b+c) ] && [ d / (h-k) ] }
The following example is not allowable syntax:
{ { [ 2 + 3 ] * 2 } / 7 }
because this expression uses two open brace '{' groups simultaneously. Also, note that parenthesis are not treated this way. You can have multiple open parenthisis groups simultaneously.

WinHoldem Formula Numeric Constants

By default all numeric constants are treated as double floating point values in base 10.
Floating Point
Numeric Constants
123.456
0.987
192837465
.5
17.
5.4321e-76

Integer Numeric Base

There are 4 additional integer options available as well that allow you to select the base of the constant. The 4 available bases are: 16, 8, 4, 2. You must prefix a numeric constant with a zero followed by a letter that selects the specific base you desire. The letters to select each base are as follows:

Integer Numeric Base
Letter Base Name
x 16 Hex
o 8 Octal*
q 4 Quadal*
b 2 Binary*
* non-standard ANSI C

Integer Numeric Constants
Decimal Hex Octal Quadal Binary
0 0x0 0o0 0q0 0b0
1 0x1 0o1 0q1 0b1
2 0x2 0o2 0q2 0b10
3 0x3 0o3 0q3 0b11
4 0x4 0o4 0q10 0b100
5 0x5 0o5 0q11 0b101
6 0x6 0o6 0q12 0b110
7 0x7 0o7 0q13 0b111
8 0x8 0o10 0q20 0b1000
9 0x9 0o11 0q21 0b1001
10 0xa 0o12 0q22 0b1010
11 0xb 0o13 0q23 0b1011
12 0xc 0o14 0q30 0b1100
13 0xd 0o15 0q31 0b1101
14 0xe 0o16 0q32 0b1110
15 0xf 0o17 0q33 0b1111
16 0x10 0o20 0q100 0b10000
31 0x1f 0o37 0q133 0b11111
63 0x3f 0o77 0q333 0b111111
127 0x7f 0o177 0q1333 0b1111111
255 0xff 0o377 0q3333 0b11111111