Syntax - jbosh/calculator GitHub Wiki
Regular
- 20 = 20
Hex
- 0x0123456789abcdef = 81,985,529,216,486,895 case insensitive
Binary
- 0b0100101 = 37
Scientific
- 20e2 = 2,000 case insensitive
You can use ()
or []
as parenthesis. Technically {}
works as parenthesis if you don't have a semicolon in there.
There is also a setting to make the ^
operator be either xor or raised to a power.
2^2
= 4 or 2**2
= 4
Or when doing xor
2^1
= 3
2**1
= 2 always.
~
does binary negation also.
For those of you from C++ land, you know about the ternary operator. a ? b : c
is the syntax. Wikipedia link.
if (a)
return b
else
return c
You can use commas wherever you want, they just get dropped.
20,10381401
= 20,103,813,01 = 2,010,381,301
0x10424984
= 0x1042,4984
Similarly C++11 syntax works.
For example 1'200'301
== 1,200,301
Sometimes parentheses are generated for you.
Say you're halfway through typing and you wanna multiply something by a big number at the end.
13 + 12 * 17 ** 2
= 3,481
Just add a parenthesis at the end!
13 + 12 * 17 ** 2) 12
= 3,481 * 12 = 41,772
The calculator will automatically put any stray parenthesis at the very beginning of the line.
You can use implicit multiplication to avoid typing.
2sin(3)
= 0.1 -> 2 * sin (3)
This works on variables too (assuming the number comes first).
4c
= 1,199,169,832
c4
= NaN though because c4 can be a variable.
c 4
= 1,199,169,832 because the space lets the calculator know it's not a single token.
{1;1;2}
= you know what this equals.
{1;1;{2;3}}
is a vector you can use. Good luck mathing it though.
{1;1;{2;3}} + {4;7;{9;23}}
= {5; 8; {11; 26}} works though if you're into that kind of thing.
dot{{1;2;1};{2;4;2}}
= 12 is how you do a dot product (because it takes multiple parameters.
cross{{1;2;1};{2;4;2}}
= {0; 0; 0} works also.
normalize {2;4;2}
= {0.41; 0.82; 0.41} to normalize vectors.
length {2;4;2}
= 4.9 is a real thing too.
sin {2;4;2}
= {0.03; 0.07; 0.03} you can use any operator on vectors and they'll try their best to operate.