Skip to content

erlsci/rationals

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rationals

Build Status Erlang Versions Tag

Project Logo

Rational numbers in Erlang

Build & Test

$ rebar3 compile
$ rebar3 check

Usage

1> Third = rationals:new(1, 3).
{fraction,1,3}
2> Quarter = rationals:new(1, 4).
{fraction,1,4}
3> rationals:numerator(Quarter).
1
4> rationals:denominator(Quarter).
4
5> rationals:add(Quarter, Third).
{fraction,7,12}
6> rationals:multiply(Quarter, Third).
{fraction,1,12}
7> rationals:gcd(64, 72).
8

See more examples in test/rationals_SUITE.erl; see rationals.erl for implementation details.

License

Copyright © 2021, Erlang-Aided Enrichment Center

Copyright © 2014 Peter Morgan [email protected]

Packages

No packages published

Languages

  • Erlang 100.0%