Programming Calculator

Hex, binary, byte manipulation, and JS syntax support.

Instacalc supports most JS syntax for hex and byte manipulation:

Computing…

A few notes:

  • While most JS syntax is allowed (if/else, ? :, "some string"), including user-defined functions and arrow functions, loops (for, while) are currently not supported.
  • Data units (GB, MB) are base 2 (help text explains this). Use MB_SI for base 10.
  • Functions can be called in several ways:
    • 123 as bin
    • 123 -> bin
    • bin(123)

Custom Functions

Define your own functions in several syntaxes — try editing them:

Computing…

Array Methods

Instacalc supports functional methods for processing arrays:

Computing…

The utility methods read the same way:

Computing…

Pipeline Examples

The pipeline operator (->) chains array operations left to right. Write it on one line, or — for readability — put each step on its own row and start the row with -> to continue from the row above. Edit any line and watch it flow down:

Computing…

sort() takes an optional comparator or key function: [3,1,2].sort((a,b) => b - a) => 3,2,1 (descending), or list.sort(x => -x) to sort by a computed key. Most statistical functions (sum, avg, median, stdev, etc.) can be called as methods on arrays.

  • Bitwise operations on binary/hex values: use the keywords and, or, xor, not (e.g. 0x123 xor 0x456 => 0x0575). The symbols & and | also work for AND/OR. Use xor for exclusive-or, not ^^ is exponentiation (0x123 ^ 0x456 evaluates as a power, not XOR).

Example

Bitwise operations and base conversions, live — edit any row:

Computing…