Skip to main content

Module signed

Module signed 

Source
Expand description

Signed arithmetic for geometry computations.

Move lacks native signed integers, so it uses (magnitude: u128, negative: bool) pairs. Rust has native i128, so we use it directly — behavior matches signed.move exactly.

Key function: cross_sign(ax,ay, bx,by, cx,cy) → i128 Computes (B−A) × (C−A), the 2D cross product used for convexity and orientation. Always cast i64 → i128 BEFORE multiplying to prevent overflow.

Functions§

cross_sign
Compute (B−A) × (C−A) cross product for three 2D points A, B, C.
is_collinear
True if cross product indicates collinearity (zero).
is_left_turn
True if cross product indicates a left turn (strictly positive).
is_right_turn
True if cross product indicates a right turn (strictly negative).
sign
Sign of a value: +1, 0, or -1.
sub_u64
Signed subtraction of two u64 values, returning i128. Equivalent to signed::sub_u64() in signed.move:56-62.