Decrement Integer Digits
Subtract a value from each digit independently with wraparound, borrow, or clamp modes. Batch input. Free, offline, client-side, instant, secure.
Subtract a value from each digit of an integer independently with three underflow modes: wraparound, borrow, clamp.
How to Use Decrement Integer Digits
- Paste integers (one per line, or comma/semicolon-separated). Mixed signs OK.
- Set the decrement value: 1 means subtract 1 from each digit (5 → 4, 9 → 8). Negative values invert to addition.
- Pick an underflow mode for what happens when a digit goes below 0:
- Wraparound: 0 − 1 = 9 (digits wrap independently in mod 10).
- Borrow: standard multi-digit arithmetic - borrow from the next position. 20 − 1-per-digit = 19. Negative results preserve sign.
- Clamp: stays at 0 (no underflow data lost - useful for sanitizing).
- Pick output separator (newline / comma / space).
- Load a sample - the wraparound, borrow, and clamp demos show each mode's distinct behavior on the same inputs.
- Press Ctrl+Enter to recalculate. Live preview after 200 ms.
Frequently Asked Questions
Wraparound vs Borrow vs Clamp – which?
Wraparound (default): each digit is treated independently. 0 − 1 wraps to 9, regardless of neighbors. 100 − 1-each-digit becomes 099 (or just 99 depending on display). Useful for ciphers, digit permutations, and demonstrating mod-10 arithmetic.
Why are there separate Underflow / Borrow / Clamp labels?
Same counter (underflows) but different meaning in each mode: in wraparound, it’s “how many digits wrapped past 0” (data preserved via mod, just visualized differently); in borrow, it’s “how many integers went negative” (sign flipped); in clamp, it’s “how many digits were saturated at 0 or 9” (data lost via clamping). The label updates with the mode so the meaning matches.
What about negative decrement values?
Negative decrement = ADD. The math is symmetric: x − (−1) = x + 1. So decrement value = −3 in wraparound mode shifts each digit UP by 3 with wraparound at 9 → 0. Useful for symmetric calculations and undoing decrements without switching tools. The “Negative dec adds” sample demonstrates.
How are negative input integers handled?
Sign preserved, digits decremented on absolute value. -542 with decrement 1 in wraparound → -431. The leading minus sign is treated as metadata, not a digit. In borrow mode, if the digit-result goes negative, the sign FLIPS: -543 with decrement 9 each digit (= subtract 999) → −543 − 999 = −1542, but if we think of it as |543| − 999 = −456, with the input’s negative sign, you get −(−456) = 456 → wait, this is getting confusing. In practice the tool’s borrow mode does: take absolute value, do subtraction, if result is negative, flip the input sign. Use wraparound or clamp for cleaner semantics on negatives.
What happens with leading zeros in the output?
Wraparound mode preserves them as strings: 100 − 1-each-digit wraparound = 099. Borrow mode strips leading zeros (treats result as a number): 100 − 1-each-digit borrow = 89 (since 100 − 11 = 89). For digit-puzzle use cases (where you care about the per-digit visualization), use wraparound; for arithmetic use cases, use borrow.
How fast can this process?
Tested at 100k integers under 250ms on a typical desktop. The bottleneck is browser DOM update for the output textarea, not the math.
What input formats are accepted?
Newlines, commas, or semicolons as separators (any combination). Only strict integer tokens are processed – fractional like 3.14 or non-numeric like foo are silently skipped (count is shown in the diagnostic if non-zero). Negative integers must use a leading minus, not surrounded by parentheses or postfixed.
Why is this useful?
Number puzzles and ciphers where each digit position matters independently. Generating sequences with predictable per-digit relationships (e.g., 123 → 234 → 345). Demonstrating modular arithmetic to students. Sanitizing IDs by clamping out-of-range digit modifications. Round-tripping with the companion “Increment Integer Digits” tool to verify reversibility.
Is my data secure?
Yes. All processing happens in your browser using vanilla JavaScript. Integers never leave your device. Download is generated in-memory and offered locally.