Coder Social home page Coder Social logo

hoangpq / insect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sharkdp/insect

0.0 2.0 0.0 1.63 MB

High precision scientific calculator with support for physical units

Home Page: https://insect.sh

License: MIT License

HTML 8.65% JavaScript 3.73% CSS 11.35% PureScript 76.27%

insect's Introduction

insect

A high precision scientific calculator with full support for physical units.

Documentation

  • Evaluate mathematical expressions:

    1920/16*9
    2^32
    sqrt(1.4^2 + 1.5^2) * cos(pi/3)^2
    
    • Operators: addition (+), subtraction (-), multiplication (*, ·, ×), division (/, ÷, per), exponentiation (^, **). Full list: see Reference below.

    • Mathematical functions: acos, acosh, asin, asinh, atan, atanh, ceil, cos, cosh, exp, floor, gamma, ln, log, log10, round, sin, sinh, sqrt, tan, tanh.

    • Arbitrary-precision numeric type that can handle very large (or small) exponents like 10^(10^10).

    • Exponential notation: 6.022e23.

  • Physical units: parsing and handling, including metric prefixes:

    2 min + 30 s
    40 kg * 9.8 m/s^2 * 150 cm
    sin(30°)
    
    • Supported units: see Reference section below.

    • Implicit conversions: 15 km/h * 30 min evaluates to 7.5 km.

    • Useful error messages:

      > 2 watts + 4 newton meter
      
      Unification error:
        Cannot convert unit N·m (base units: kg·m²·s⁻²)
                    to unit W (base units: kg·m²·s⁻³)
      
  • Explicit unit conversions: the -> conversion operator (aliases: , to):

    60 mph -> m/s
    500 km/day -> km/h
    1 mrad -> degree
    52 weeks -> days
    5 in + 2 ft -> cm
    atan(30 cm / 2 m) -> degree
    6 Mbit/s * 1.5 h -> GB
    
  • Variable assignments:

    r = 6000km
    vol = 4/3 * pi * r^3
    density = 5 g/cm^3
    vol * density -> kg
    
    len = 20 cm
    2pi*sqrt(len/g0) -> ms
    
    • Predefined constants (type list to see them all): speed of light (c), Planck's constant (h_bar), electron mass (electronMass), elementary charge (elementaryCharge), magnetic constant (µ0), electric constant (eps0), Bohr magneton (µ_B), Avogadro's constant (N_A), Boltzmann constant (k_B), gravitational acceleration (g0), ...

    • Last result: you can use ans (answer) to refer to the result of the last calculation.

  • Unicode support:

    λ = 2 × 300 µm
    ν = c/λ → GHz
    
  • And more: tab completion, command history (arrow keys, Ctrl+R), pretty printing, syntax highlighting, ...

Reference

  • Operators (ordered by precedence: high to low)

    Operator Syntax
    factorial !
    square/cube ²/³
    exponentiation ^, **
    multiplication (implicit) whitespace
    division /, ÷, per
    multiplication (explicit) *, ·, ×
    subtraction -
    addition +
    unit conversion ->, , to
    assignment =

    Note that implicit multiplication has a higher precedence than division, i.e. 50 cm / 2 m will be parsed as 50 cm / (2 m).

  • Commands

    Command Syntax
    help text help, ?
    list of variables list, ls, ll
    reset environment reset
    clear screen clear, cls
    quit (CLI) quit, exit
  • Supported units (remember that you can use tab completion). All SI-accepted units support metric prefixes.

    Unit Syntax
    Ampere amperes, ampere, A
    Ångström angstrom, Å
    Astronomical unit AU
    Bar bar
    Barn barn
    Becquerel becquerel, Bq
    Bel bel
    Bits per second bps
    Bit bits, bit
    Byte Bytes, bytes, Byte, byte, B
    Candela candela, cd
    Coulomb coulomb, C
    Cup cups, cup
    Day days, day, d
    Degree degrees, degree, deg, °
    Electronvolt electronvolt, eV
    Farad farad, F
    Foot feet, foot, ft
    Gallon gallons, gallon, gal
    Gauss gauss
    Gram grams, gram, g
    Gray gray, Gy
    Hectare hectare, ha
    Henry henry, H
    Hertz hertz, Hz
    Hour hours, hour, h
    Inch inches, inch, in
    Joule joules, joule, J
    Katal katal, kat
    Kelvin kelvin, K
    Liter liters, liter, L
    Lumen lumen, lm
    Lux lux, lx
    Meter meters, meter, m
    Miles per hour mph
    Mile miles, mile
    Minute minutes, minute, min
    Mole mole, mol
    Month months, month
    Newton newton, N
    Ohm ohms, ohm, Ω
    Ounce ounces, ounce, oz
    Pascal pascal, Pa
    Pint pints, pint
    Pound pounds, pound, lb
    Radian radians, radian, rad
    Second seconds, second, sec, s
    Siemens siemens, S
    Sievert sievert, Sv
    Tablespoon tablespoons, tablespoon, tbsp
    Teaspoon teaspoons, teaspoon, tsp
    Tesla tesla, T
    Tonne tonnes, tonne, tons, ton, t
    Volt volts, volt, V
    Watt watts, watt, W
    Watt-hour Wh
    Weber weber, Wb
    Week weeks, week
    Yard yards, yard, yd
    Year years, year

Install terminal version

In addition to the web interface, there is also a command line version which can by installed via npm:

npm install -g insect

For Arch Linux, there is a package on AUR:

yaourt -S insect

For macOS, there is a Homebrew package:

brew install insect

Development

Insect is written in PureScript (see Getting Started guide). You can install all dependencies and build the whole project by running:

bower install
npm install
pulp -w browserify --skip-entry-point -m Insect --standalone Insect -O -t insect.js

Insect comes with a comprehensive set of unit tests. You can run them by calling

pulp test

insect's People

Contributors

5310 avatar caleb-an avatar geoffreyfrogeye avatar mandulaj avatar mbarkhau avatar peteryates avatar sharkdp avatar zelpa avatar zmwangx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.