{"id":18510027,"url":"https://github.com/lfex/horatio","last_synced_at":"2025-05-14T11:14:07.378Z","repository":{"id":36904088,"uuid":"41211107","full_name":"lfex/horatio","owner":"lfex","description":"The rational and most trusted friend of the tragic hero, Floating Point","archived":false,"fork":false,"pushed_at":"2016-11-20T10:27:05.000Z","size":56,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-25T21:17:05.870Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lfex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-22T14:35:43.000Z","updated_at":"2016-10-29T15:49:27.000Z","dependencies_parsed_at":"2022-09-09T13:21:02.571Z","dependency_job_id":null,"html_url":"https://github.com/lfex/horatio","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Fhoratio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Fhoratio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Fhoratio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfex%2Fhoratio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lfex","download_url":"https://codeload.github.com/lfex/horatio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239225764,"owners_count":19603158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T15:20:16.688Z","updated_at":"2025-02-17T02:41:09.670Z","avatar_url":"https://github.com/lfex.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# horatio\n\n[![Build Status][travis badge]][travis] [![LFE Versions][lfe badge]][lfe] [![Erlang Versions][erlang badge]][versions] [![Tags][github tags badge]][github tags] [![Downloads][hex downloads]][hex package]\n\n[![Horatio logo][logo]][logo]\n\n*The rational and most trusted friend of the tragic hero, Floating Point*\n\n\n## Table of Contents\n\n* [Introduction](#introduction-)\n* [Installation](#installation-)\n* [Usage](#usage-)\n  * [Creating Fractions](#creating-fractions-)\n  * [Convenience Functions](#convenience-functions-)\n    * [Printing](#printing-fractions-)\n    * [Converting](#converting-)\n  * [Math](#math-)\n    * [Arithmatic](#arithmatic-)\n    * [Operations](#operations-)\n    * [Powers](#powers-)\n* [API](#api-)\n* [License](#license-)\n\n\n## Introduction [\u0026#x219F;](#table-of-contents)\n\nAdd content to me here!\n\n\n## Installation [\u0026#x219F;](#table-of-contents)\n\nJust add it to your ``rebar.config`` deps:\n\n```erlang\n{deps, [\n  ...\n  {horatio, \".*\",\n    {git, \"git@github.com:lfex/horatio.git\", \"master\"}}\n    ]}.\n```\n\nAnd then do the usual:\n\n```bash\n$ rebar get-deps\n$ rebar compile\n```\n\n\n## Usage [\u0026#x219F;](#table-of-contents)\n\n### Creating Fractions [\u0026#x219F;](#table-of-contents)\n\nYou may create frations using any one of the following:\n\n```lfe\n\u003e (ratio:new 2 3)\n#(ratio 2 3)\n\u003e (ratio:new \"2/3\")\n#(ratio 2 3)\n\u003e (ratio:new '2/3)\n#(ratio 2 3)\n\u003e (ratio:new #(2 3))\n#(ratio 2 3)\n```\n\n### Convenience Functions [\u0026#x219F;](#table-of-contents)\n\n#### Printing Fractions [\u0026#x219F;](#table-of-contents)\n\n```lfe\n\u003e (set r (ratio:new 2 3))\n#(ratio 2 3)\n\u003e (ratio:print r)\n2/3\nok\n```\n\nYou can also use the alias ``pp`` (for \"pretty print\"):\n\n```lfe\n\u003e (ratio:pp r)\n2/3\nok\n```\n\n#### Converting [\u0026#x219F;](#table-of-contents)\n\nTo strings, atoms, and floats:\n\n```lfe\n\u003e (ratio:-\u003estr r)\n\"2/3\"\n\u003e (ratio:-\u003eatom r)\n2/3\n\u003e (ratio:-\u003efloat r)\n0.6666666666666666\n```\n\nFloats to rational numbers:\n\n```lfe\n\u003e (ratio:float-\u003eratio 0.5)\n#(ratio 1 2)\n\u003e (ratio:float-\u003eratio 1.5)\n#(ratio 3 2)\n\u003e (ratio:float-\u003eratio 3.1415)\n#(ratio 6283 2000)\n```\n\n### Math [\u0026#x219F;](#table-of-contents)\n\nFor the following examples we'll use these rational numbers:\n\n```lfe\n\u003e (set r1 (ratio:new '1/3))\n#(ratio 1 3)\n\u003e (set r2 (ratio:new '1/4))\n#(ratio 1 4)\n```\n\n#### Arithmatic [\u0026#x219F;](#table-of-contents)\n\nAddition:\n\n```lfe\n\u003e (ratio:pp (ratio:add r1 r2))\n7/12\nok\n```\n\nSubtraction:\n\n```lfe\n\u003e (ratio:pp (ratio:sub r1 r2))\n1/12\nok\n```\n\nMultiplication:\n\n```lfe\n\u003e (ratio:pp (ratio:mult r1 r2))\n1/12\nok\n```\n\nDivision:\n\n```lfe\n\u003e (ratio:pp (ratio:div r1 r2))\n4/3\nok\n```\n\n#### Operations [\u0026#x219F;](#table-of-contents)\n\n```lfe\n\u003e (ratio:eq r1 r2)\nfalse\n\u003e (ratio:eq r2 r2)\ntrue\n```\n#### Powers [\u0026#x219F;](#table-of-contents)\n\n```lfe\n\u003e (ratio:pp (ratio:pow r1 4))\n1/81\nok\n\u003e (ratio:pp (ratio:pow r1 -4))\n81/1\nok\n\u003e (ratio:pp (ratio:pow r2 4))\n1/256\nok\n\u003e (ratio:pp (ratio:pow r2 -4))\n256/1\nok\n```\n\nLarge numbers:\n\n```lfe\n\u003e (ratio:pp (ratio:div (ratio:pow 3 200) (ratio:pow 2 430)))\n8960496791105607/93536104789177786765035829293842113257979682750464\nok\n```\n\n## API [\u0026#x219F;](#table-of-contents)\n\nThe list of functions currently supported by the ratio library are as\nfollows:\n\n```lfe\nratio:-\u003eatom/1\nratio:-\u003efloat/1\nratio:-\u003estr/1\nratio:add/2\nratio:denom/1\nratio:div/2\nratio:eq/2\nratio:float-\u003eratio/1\nratio:gcd/2\nratio:mult/2\nratio:new/1\nratio:new/2\nratio:normalize/1\nratio:normalize/2\nratio:numer/1\nratio:pow/2\nratio:pp/1\nratio:print/1\nratio:ratio/1\nratio:ratio/2\nratio:sub/2\n```\n\n\n## License [\u0026#x219F;](#table-of-contents)\n\nApache Version 2 License\n\nCopyright © 2015-2016, Duncan McGreggor \u003coubiwann@gmail.com\u003e\n\n\n\u003c!-- Named page links below: /--\u003e\n\n[logo]: priv/images/horatio.jpg\n[org]: https://github.com/lfex\n[github]: https://github.com/lfex/horatio\n[gitlab]: https://gitlab.com/lfex/horatio\n[travis]: https://travis-ci.org/lfex/horatio\n[travis badge]: https://img.shields.io/travis/lfex/horatio.svg\n[lfe]: https://github.com/rvirding/lfe\n[lfe badge]: https://img.shields.io/badge/lfe-1.2.0-blue.svg\n[erlang badge]: https://img.shields.io/badge/erlang-R16%20to%2019.1-blue.svg\n[versions]: https://github.com/lfex/horatio/blob/master/.travis.yml\n[github tags]: https://github.com/lfex/horatio/tags\n[github tags badge]: https://img.shields.io/github/tag/lfex/horatio.svg\n[github downloads]: https://img.shields.io/github/downloads/lfex/horatio/total.svg\n[hex badge]: https://img.shields.io/hexpm/v/horatio.svg?maxAge=2592000\n[hex package]: https://hex.pm/packages/horatio\n[hex downloads]: https://img.shields.io/hexpm/dt/horatio.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfex%2Fhoratio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flfex%2Fhoratio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfex%2Fhoratio/lists"}