{"id":15608666,"url":"https://github.com/hypercubed/real","last_synced_at":"2026-02-14T03:09:52.383Z","repository":{"id":47990129,"uuid":"198372727","full_name":"Hypercubed/real","owner":"Hypercubed","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-04T05:39:12.000Z","size":895,"stargazers_count":1,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T22:43:04.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hypercubed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-23T07:06:47.000Z","updated_at":"2022-06-06T20:16:33.000Z","dependencies_parsed_at":"2023-02-01T23:31:57.095Z","dependency_job_id":null,"html_url":"https://github.com/Hypercubed/real","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Hypercubed/real","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Freal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Freal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Freal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Freal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hypercubed","download_url":"https://codeload.github.com/Hypercubed/real/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Freal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276278102,"owners_count":25615187,"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","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-03T05:21:50.049Z","updated_at":"2025-09-21T17:41:16.547Z","avatar_url":"https://github.com/Hypercubed.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real\n\n`Real` provides an object with properties and methods for mathematical constants and functions (similar to `Math`) that works with `Number` and `BigInt` as well as two additional classes (`Rational` and `Irrational`).\n\n### Usage\n\n```ts\nimport * as RealMath from '@hypercubed/real';\n```\n\n`RealMath` provides several math functions that work with `Number` and `BigInt`.  These two types, however, are not sufficient in many cases.  `@hypercubed/real` provides two additional classes that represent broader numeric types:\n\n- `Rational` - any number that can be expressed as the quotient (or fraction) of two integers (BigInt) (`p/q`)\n- `Irrational` - an approximation of a number expressed in scientific notation (`m x 10 ^ n`)\n\nWhen using the `RealMath` functions, values are converted, as necessary, for the given function.  Implict conversions are as follows:\n\n- `BigInt` -\u003e `Rational`\n- `Number` -\u003e `Irrational`\n- `Rational` -\u003e `Irrational`\n\nFor example, when using the `div` method, dividing two `BigInt` values would result in loss of precision... therefore, before the division operation `BigInt` values are converted to `Rational` values.  Similarly, `Number` values are converted to `Irrational` values.  If the division operation includes any `Irrational` values, `Rational` values are converted to `Irrational` values.\n\nSee this examples:\n\n```ts\nimport * as RealMath from '@hypercubed/real';\n\nRealMath.div(1n, 3n),toString(); // 1/3`\nRealMath.div(1n, 3),toString();  // 3.3333333333333333333e-1\n\nRealMath.div(1n, new Rational(3n)),toString();       // 1/3`\nRealMath.div(1n, new Irrational(3n)),toString();     // 3.3333333333333333333e-1\n```\n\n### Methods\n\n- `abs` - Returns the absolute value of a number.\n- `trunc` - Returns the integer part of the number x, removing any fractional digits.\n- `ceil` - Returns the smallest integer greater than or equal to a number.\n- `floor` - Returns the largest integer less than or equal to a number.\n- `add` - adds two values\n- `sub` - subtracts two values\n- `mul` - multiplies two values\n- `div` - divies two values\n- `inv` - inverts a value\n- `ln` - Returns the natural logarithm (log\u003csub\u003ee\u003c/sub\u003e) of a number\n\n## License\n\nThis project is licensed under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Freal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypercubed%2Freal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Freal/lists"}