项目作者: velnias75

项目描述 :
A small collection of tools to work with rational numbers
高级语言: C++
项目地址: git://github.com/velnias75/expr2cf.git
创建时间: 2015-10-29T08:33:56Z
项目社区:https://github.com/velnias75/expr2cf

开源协议:

下载


expr2cf

Converts a simple mathematical expression to a continued fraction sequence

Requirements

Usage/examples

  • to evaluate an expression:
    echo "2 + 0.8031975" | expr2cf => [2, 1, 4, 12, 3, 4, 2, 1, 1, 1, 1, 2, 1, 1, 5]

  • to get an approximated fraction of pi (from 18 decimal digits):
    echo "scale=18; 4*a(1)" | BC_LINE_LENGTH=0 bc -l | expr2cf | cf2expr
    => 14308127635/4554418479

  • to get an approximated fraction of the golden ratio (Phi):
    echo "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]" | cf2expr
    => 6765/4181