Skip to content
josh-wsPublic

About

A lightweight bignum calculator inspired by ivy and APL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robin

Lightweight desk calculator with arbitrary-precision arithmetic.

Inspired by Ivy and APL.

Operator precedence is right-to-left. 2*3+4 is 14, not 10.

Features

  • Arbitrary-precision arithmetic: 2 pow 99 => 633825300114114700748351602688
  • Rational numbers: 1/3 + 4/5 => 17/15
  • Scientific notation: 2.99792458e8 => 299792458
  • Hex: 0x30 + 0x20 => 80
  • Binary: 0b0010 * 0b1000101 => 138
  • Rich error diagnostics
  • Brackets for precedence: (3+5)*8 => 64

A lot of things still unimplemented. See DESIGN.

Sample

$ robin
> 1 + 2
3
> 7 add 35
42
> 5 - 12
-7
> 6 * 7
42
> neg 7
-7
> 2 * 3 + 4
14
> (2 * 3) + 4
10
> 2 * (3 + 4)
14
> 1 - 2 - 3
2
> (1 - 2) - 3
-4
> -5 + 12
-17
> 2 pow 10 mul 3
1073741824
> 2 pow 3 pow 2
512
> (2 pow 3) pow 2
64
> 1234567890 * 9876543210
12193263111263526900
> 2 pow 200
1606938044258990275541962092341162602522202993782792835301376
> 0xff + 0b1011
266
> 0x123ABCdef
4893429231
> 34/10
17/5
> 1/3 + 1/6
1/2
> 1.5 + 1/2
2
> 0.125
1/8
> 1.4e5
140000
> 0x
    ^ error: empty literal
> 1 2
    ^ error: trailing input
> 1 +
     ^ error: unexpected eof
> 1 @ 2
    ^ error: unexpected token
> (1 + 2
  ^ error: unclosed parentheses
> 2 pow -1
  ^~~~~~~~^ error: negative exponent unsupported
> 0 pow 0
  ^~~~~~~^ error: 0 pow 0 is undefined
> 1 + 2 * (0 pow 0)
          ^~~~~~~~~^ error: 0 pow 0 is undefined
> 3 * 1/0
      ^~~^ error: division by zero

About

A lightweight bignum calculator inspired by ivy and APL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages