OtterCalcOtterCalc

Advanced

The power-user and programmer corner: prev, bitwise, number bases, factorial, scientific notation, percent change.

The everyday math lives in the earlier topics. This page gathers the sharper tools in one place, for power users and programmers.

prev and line references

prev is the result of the nearest value line above, so you can build a calculation step by step without naming each one. R2 points at a specific line (the number in the left gutter). Both carry units along. See Totals & references for the full rules.

dinner = 45
with tip = prev + 18%
per person = prev / 4
R1 - R2
45
53.1
13.275
-8.1

Scientific notation

Show any result in scientific form with "in sci" (or "in scientific"). It uses the full-precision mantissa, so nothing is rounded away.

5300 in sci
0.00042 in sci
299792458 in sci
5.3e3
4.2e-4
2.99792458e8

Percent change

Measure the change between two numbers with "percent change from A to B". A drop reads as a negative percent. See Percentages for the shorter "A to B is what %" form and the other percent questions.

percent change from 40 to 50
percent change from 200 to 150
25%
-25%

Bitwise operators

Whole-number bitwise math: & (and), | (or), xor, and the shifts << and >> all work on integers.

12 & 10
6 | 1
12 xor 10
1 << 4
256 >> 2
8
7
6
16
64

Number bases

Write hex, binary or octal literals with 0x, 0b or 0o. They keep their base as you calculate, so a sum of hex stays hex. Turn any number into another base with "to hex", "to binary" or "to octal".

0xFF + 1
0b1010 + 0b0101
0o17 + 1
255 to hex
255 to binary
255 to octal
0x100
0b1111
0o20
0xFF
0b11111111
0o377

Factorial

factorial(n) or the shorthand n! multiplies every whole number down to 1.

5!
factorial(6)
10! / 8!
120
720
90

CSS and typographic units

For front-end work, px, pt, pc, em and rem convert among themselves and to physical lengths. em and rem assume the usual 16px base, so 1.5 rem is 24px.

16px in pt
1.5 rem in px
2 em in px
1 inch in px
12 pt
24 px
32 px
96 px