enum HoldSide { SHORT, LONG; static HoldSide fromInt(double direction) { if (direction > 0) ret LONG; if (direction < 0) ret SHORT; fail("direction 0"); } bool isLong() { ret this == LONG; } bool isShort() { ret this == SHORT; } }