Skip to content

Math Notebook โ€‹

>=4.6

Math Notebook is a calculator-style workspace for quick calculations, conversions, and date math inside massCode. Use it when you need to check a number, compare prices, convert units, or work through finance and time calculations without leaving your main workflow.

Write expressions in natural language and get instant results on every line.

Arithmetic โ€‹

Standard math operators and parentheses.

10 + 5         โ†’ 15
20 * 3         โ†’ 60
(2 + 3) * 4    โ†’ 20
2 ^ 10         โ†’ 1,024
5 300          โ†’ 5,300

Word Operators โ€‹

Use words instead of symbols.

8 times 9             โ†’ 72
100 plus 50           โ†’ 150
10 and 5              โ†’ 15
10 with 5             โ†’ 15
200 without 30        โ†’ 170
20 subtract 3         โ†’ 17
10 multiplied by 3    โ†’ 30
100 divide by 4       โ†’ 25
17 mod 5              โ†’ 2

Variables โ€‹

Declare variables with = and reuse them across lines.

v = 20       โ†’ 20
v times 7    โ†’ 140
v + 10       โ†’ 30

Labels โ€‹

Prefix a line with a label followed by a colon โ€” the label is ignored, only the expression is evaluated.

Price: $11 + $34.45    โ†’ 45.45 USD
Monthly: 1200 / 12     โ†’ 100

Inline Quotes โ€‹

Text inside double quotes is ignored.

$275 for the "Model 227"    โ†’ 275 USD

Percentage โ€‹

Basic percentage โ€‹

100 + 15%     โ†’ 115
200 - 10%     โ†’ 180
15% of 200    โ†’ 30

Advanced percentage โ€‹

5% on 200           โ†’ 210
5% off 200          โ†’ 190
50 as a % of 100    โ†’ 50%
70 as a % on 20     โ†’ 250%
20 as a % off 70    โ†’ 71.43%
5% of what is 6     โ†’ 120
5% on what is 6     โ†’ 5.71
5% off what is 6    โ†’ 6.32

Percentage change โ€‹

50 to 75 is what %       โ†’ 50%
40 to 90 as %            โ†’ 125%
180 is what % off 200    โ†’ 10%
180 is what % on 150     โ†’ 20%
20 is what % of 200      โ†’ 10%

Fractions & multipliers โ€‹

2/10 as fraction      โ†’ 1/5
50% as fraction       โ†’ 1/2
0.25 as fraction      โ†’ 1/4
20/5 as multiplier    โ†’ 4x
50 as x of 5          โ†’ 10x
50 to 75 is what x    โ†’ 1.5x

Decimal/percentage conversion โ€‹

0.35 as %         โ†’ 35%
20/200 as %       โ†’ 10%
20% as dec        โ†’ 0.2
50% to decimal    โ†’ 0.5

Scales โ€‹

Shorthand for large numbers. One-letter scales are case-sensitive: k for thousands, M for millions.

$2k            โ†’ 2,000 USD
3M             โ†’ 3,000,000
1.5 billion    โ†’ 1,500,000,000
10 thousand    โ†’ 10,000

Currency โ€‹

Supports 166+ fiat currencies (ISO 4217 codes), 21 cryptocurrencies, common currency symbols, and word names. Live exchange rates with cached fallback.

Supported symbols โ€‹

SymbolCurrency
$USD
โ‚ฌEUR
ยฃGBP
ยฅJPY
โ‚ฝRUB
โ‚ดUAH
โ‚ฉKRW
โ‚นINR
CA$CAD
AU$AUD
HK$HKD
NZ$NZD
R$BRL

Cryptocurrencies
>=5.0
โ€‹

BTC, ETH, SOL, DOGE, XRP, ADA, DOT, LTC, AVAX, SHIB, BNB, USDT, USDC, XLM, XMR, EOS, TRX, DASH, NEO, BCH, ETC.

Custom exchange rates
>=5.0
โ€‹

50 EUR in USD at 1.05 USD/EUR    โ†’ 52.50 USD
$30 + $15                 โ†’ 45 USD
$30 to EUR                โ†’ ... EUR (live rate)
โ‚ฌ50 + ยฃ20                 โ†’ ... EUR (live rate)
5 dollars + 10 dollars    โ†’ 15 USD

Unit Conversion โ€‹

Use to, in, as, into for conversion.

5 km to mile                 โ†’ 3.10686 mile
5 km into mile               โ†’ 3.10686 mile
1 inch in cm                 โ†’ 2.54 cm
100 celsius to fahrenheit    โ†’ 212 fahrenheit
1 kg to lb                   โ†’ 2.20462 lb
1 meter 20 cm                โ†’ 1.2 m
1 meter 20 cm into cm        โ†’ 120 cm
1 point to inch              โ†’ 0.0138889 inch
1 are to m^2                 โ†’ 100 m^2
1 degree to radian           โ†’ 0.0174533 radian
1 nautical mile to mile      โ†’ 1.15078 mile

Supported unit categories โ€‹

  • Length: meter, inch, foot, yard, mile, nautical mile, point, line, hand, furlong, cable, league, etc.
  • Weight: gram, kg, pound, ounce, tonne, stone, carat, etc.
  • Temperature: celsius, fahrenheit, kelvin
  • Time: second, minute, hour, day, week, month, year
  • Angular: radian, degree, and ยฐ
  • Data: bit, byte, KB, MB, GB, TB (with SI and binary prefixes)
  • Area: mยฒ, hectare, acre, are, plus aliases like sq, square, sqm
  • Volume: liter, gallon, pint, quart, cup, teaspoon, tablespoon, plus aliases like cu, cubic, cb, cbm

CSS Units โ€‹

Supports CSS-oriented px, pt, and em conversions with configurable ppi and em.

12 pt in px     โ†’ 16 px
em = 20px
1.2 em in px    โ†’ 24 px
ppi = 326
1 cm in px      โ†’ 128.35 px

Rounding โ€‹

1/3 to 2 dp                   โ†’ 0.33
pi to 5 digits                โ†’ 3.14159
5.5 rounded                   โ†’ 6
5.5 rounded down              โ†’ 5
5.5 rounded up                โ†’ 6
37 to nearest 10              โ†’ 40
2100 to nearest thousand      โ†’ 2,000
21 rounded up to nearest 5    โ†’ 25
490 to nearest hundred        โ†’ 500

Math Functions โ€‹

sqrt(16)       โ†’ 4
sqrt 16        โ†’ 4
cbrt 8         โ†’ 2
root 2 (8)     โ†’ 2.8284
sin(45 deg)    โ†’ 0.7071
sin 45ยฐ        โ†’ 0.7071
cos(pi)        โ†’ -1
log(100)       โ†’ 2
log 2 (8)      โ†’ 3
ln(e)          โ†’ 1
abs(-42)       โ†’ 42
round(3.7)     โ†’ 4
round 3.45     โ†’ 3
ceil(3.2)      โ†’ 4
floor(3.9)     โ†’ 3
fact(5)        โ†’ 120
arcsin(1)      โ†’ 1.5708
arccos(1)      โ†’ 0
arctan(1)      โ†’ 0.7854

Number Formats โ€‹

Append in hex, in bin, in oct, or in sci to format the result.

255 in hex      โ†’ 0xFF
10 in bin       โ†’ 0b1010
255 in oct      โ†’ 0o377
5300 in sci     โ†’ 5.3e+3
5 300 in sci    โ†’ 5.3e+3

Input also supports hex, binary, and octal literals:

0xFF      โ†’ 255
0b1010    โ†’ 10
0o377     โ†’ 255

Previous Result โ€‹

Use prev to reference the result from the previous line.

10 + 5      โ†’ 15
prev * 2    โ†’ 30
prev - 5    โ†’ 25

Sum & Total โ€‹

sum or total calculates the sum of all numeric results above (until an empty line).

10 + 5    โ†’ 15
20 * 3    โ†’ 60
sum       โ†’ 75

Average โ€‹

average or avg calculates the mean of all numeric results above (until an empty line).

10
20
30
average    โ†’ 20

Comments โ€‹

Lines starting with // or # are treated as comments and produce no result.

// This is a comment
# This is also a comment

Date & Time โ€‹

Many date and time results depend on your current date, locale, and time zone, so some examples below show relative output rather than one fixed value.

Current time โ€‹

time              โ†’ (current time)
now               โ†’ (current date & time)
now()             โ†’ (current date & time)
time() + 1 day    โ†’ (tomorrow)
now + 1 day       โ†’ (tomorrow)

Calendar โ€‹

days since January 1                   โ†’ ... days
days till December 25                  โ†’ ... days
days between March 1 and March 31      โ†’ 30 days
5 days from now                        โ†’ (date)
3 days ago                             โ†’ (date)
3 months from now                      โ†’ (date)
2 years ago                            โ†’ (date)
3 weeks after March 14, 2019           โ†’ (date)
28 days before March 12                โ†’ (date)
day of the week on January 24, 1984    โ†’ Tuesday
week of year                           โ†’ (current week number)
week number on March 12, 2021          โ†’ (week number)
days in February 2020                  โ†’ 29 days
days in Q1                             โ†’ 90 days

Timestamps โ€‹

current timestamp               โ†’ (unix timestamp)
January 1, 2020 to timestamp    โ†’ 1577836800
fromunix(1446587186)            โ†’ 11/3/2015, ...
1733823083000 to date           โ†’ (date)
June 15, 2020 as iso8601        โ†’ 2020-06-15T00:00:00.000Z
2019-04-01T15:30:00 to date     โ†’ (date)

Time arithmetic follows Numi-like semantics: 1 year = 365 days, 1 month = 365 / 12 days.

Time zone conversion โ€‹

Zones can be specified as:

  • Timezone codes: PST, EST, CET, JST, etc.
  • Airport codes
    >=5.0
    : LAX, JFK, SFO, NRT, CDG, SYD, etc.
  • City names
    >=5.0
    : Seattle, Berlin, Tokyo, Dubai, etc.
  • Country names
    >=5.0
    : Japan, Germany, France, etc.
PST time                                      โ†’ (current time in PST)
New York time                                 โ†’ (current time in New York)
Time in Madrid                                โ†’ (current time in Madrid)
time in Tokyo                                 โ†’ (current time in Tokyo)
7:30 am LAX in Japan                          โ†’ (converted time)
time difference between Seattle and Moscow    โ†’ ... hours
2:30 pm HKT in Berlin                         โ†’ (converted time)
2:30 pm New York in Berlin                    โ†’ (converted time)
2026-03-06 PST in Berlin                      โ†’ (converted date)
tomorrow PST in Berlin                        โ†’ (converted date)

Time unit arithmetic:

1 month in days           โ†’ 30.4167 days
round(1 month in days)    โ†’ 30
round 1 month in days     โ†’ 30
2 hours + 30 minutes      โ†’ 2.5 hours

Constants โ€‹

pi     โ†’ 3.1415926536
e      โ†’ 2.7182818285
tau    โ†’ 6.2831853072
phi    โ†’ 1.6180339887

Bitwise Operations โ€‹

5 & 3      โ†’ 1
5 | 3      โ†’ 7
5 xor 3    โ†’ 6
1 << 4     โ†’ 16
16 >> 2    โ†’ 4
6 (3)      โ†’ 18

SI Prefixes โ€‹

SI-based units support all SI prefixes (case-sensitive):

1 mm     โ†’ 0.001 m
3 GB     โ†’ 3e+9 bytes
2 MHz    โ†’ 2,000,000 Hz

Finance โ€‹

>=5.0

Compound interest โ€‹

$1,000 after 3 years at 7%                                        โ†’ $1,225.04
$1,000 for 3 years at 7% compounding monthly                      โ†’ $1,232.93
$1,000 for 3 years at 7% compounding quarterly                    โ†’ $1,231.44
interest on $1,000 after 3 years @ 7%                             โ†’ $225.04
$500 invested $1,500 returned                                     โ†’ 3x
annual return on $1,000 invested $2,500 returned after 7 years    โ†’ 13.99%
present value of $1,000 after 20 years at 10%                     โ†’ $148.64
monthly repayment on $10,000 over 6 years at 6%                   โ†’ $165.73
total repayment on $10,000 over 6 years at 6%                     โ†’ $11,932.48
total interest on $10,000 over 6 years at 6%                      โ†’ $1,932.48

Cooking Conversions โ€‹

>=5.0

130+ food substances with density data for accurate volume-to-mass and mass-to-volume conversions.

density of yogurt             โ†’ 1.06 g/cmยณ
density of olive oil          โ†’ 0.916 g/cmยณ
300g butter in cups           โ†’ ~1.39 cups
10 cups olive oil in grams    โ†’ ~2,168 grams

Supports cups, tablespoons, teaspoons, fl oz, pints, quarts, and gallons.

Video & Timecode โ€‹

>=5.0

Timecode format HH:MM:SS:FF with at or @ to specify frame rate (default 24 fps).

00:30:10:00 @ 24 fps in frames       โ†’ 43,440 frames
03:10:20:05 at 30 fps + 50 frames    โ†’ (timecode)
30 fps * 3 minutes                   โ†’ 5,400 frames

Workday Calculations โ€‹

>=5.0
workdays in 3 weeks                 โ†’ 15 workdays
workdays from March 3 to March 7    โ†’ ... workdays
2 workdays after March 3, 2025      โ†’ (date)

Clock Time Intervals โ€‹

>=5.0
7:30 to 20:45    โ†’ 13 hours 15 min
4pm to 3am       โ†’ 11 hours
9am to 5pm       โ†’ 8 hours

Midnight crossing is handled automatically.

Timespan & Laptime โ€‹

>=5.0

Timespan โ€‹

5.5 minutes as timespan    โ†’ 5 min 30 s
72 days as timespan        โ†’ 10 weeks 2 days

Laptime โ€‹

5.5 minutes as laptime            โ†’ 00:05:30
03:04:05 + 01:02:03 as laptime    โ†’ 04:06:08

Stacked time โ€‹

3h 5m 10s    โ†’ 11,110 seconds

Base N Conversion โ€‹

>=5.0

Convert between arbitrary bases.

0b101101 as base 8    โ†’ 0o55
0xFF as base 2        โ†’ 0b11111111

Python-style functions:

hex(99)      โ†’ 0x63
bin(0x73)    โ†’ 0b1110011
int(0o55)    โ†’ 45

Large Numbers โ€‹

>=5.0

Use B/bn for billion and T/tn for trillion, or word forms.

10 trillion    โ†’ 10,000,000,000,000

Additional Functions โ€‹

>=5.0
larger of 100 and 200             โ†’ 200
smaller of 5 and 10               โ†’ 5
half of 175                       โ†’ 87.5
midpoint between 150 and 300      โ†’ 225
random number between 1 and 10    โ†’ (random)
gcd of 20 and 30                  โ†’ 10
lcm of 5 and 8                    โ†’ 40
10 permutation 3                  โ†’ 720
25 combination 3                  โ†’ 2,300
clamp 26 between 5 and 25         โ†’ 25

Proportions โ€‹

>=5.0
6 is to 60 as 8 is to what     โ†’ 80
5 is to 10 as what is to 80    โ†’ 40

Conditions โ€‹

>=5.0
if 5 > 3 then 10 else 20    โ†’ 10
42 if 5 > 3                 โ†’ 42
42 unless 5 > 3             โ†’ 0
5 > 3 and 10 > 7            โ†’ true

Comment Syntax โ€‹

>=5.0

End-of-line comments and parenthesized remarks are stripped before evaluation.

100 + 20 // add 20
$999 (for iPhone)

Preferences โ€‹

>=5.0

Math Notebook has configurable preferences:

  • Locale โ€” 14 languages for number and date formatting
  • Decimal places โ€” 0 to 14
  • Date format โ€” Numeric, Short, Long
  • Refresh buttons for fiat and crypto exchange rates

massCode released under the AGPL v3 License.
Snippet collection released under the CC-BY-4.0 License.