JS Built-ins
← Math132 / 215
Mathimulbeginner

Math.imul() β€” Negative Γ— Negative

πŸ“– Usage Example
// 32-bit integer multiplication (C-like overflow)
Math.imul(3, 4)    // β†’ 12
Math.imul(-1, 8)   // β†’ -8

Use Math.imul() for fast 32-bit integer multiplication with C-like overflow semantics, useful in hashing or WebAssembly.

Math.imul()

Performs C-like 32-bit integer multiplication.

Challenge: Verify that Math.imul(-1, -1) returns 1.

πŸ’‘ Hints (1)
  • β€’ Negative Γ— negative = positive, even in 32-bit integer math