{"id":51133663,"url":"https://github.com/trananhtung/numan","last_synced_at":"2026-06-27T17:00:28.750Z","repository":{"id":366615116,"uuid":"1275866646","full_name":"trananhtung/numan","owner":"trananhtung","description":"Humanize numbers in Rust: compact (1.2K), word (1.2 million), SI metric (1.2 k) notation + parsing. Zero-dep, no_std.","archived":false,"fork":false,"pushed_at":"2026-06-22T14:43:46.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-22T16:26:04.700Z","etag":null,"topics":["cli","crates-io","formatting","humanize","no-std","number-formatting","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trananhtung.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-21T08:31:17.000Z","updated_at":"2026-06-22T14:45:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/trananhtung/numan","commit_stats":null,"previous_names":["trananhtung/numan"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/trananhtung/numan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Fnuman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Fnuman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Fnuman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Fnuman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trananhtung","download_url":"https://codeload.github.com/trananhtung/numan/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Fnuman/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34780126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"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":["cli","crates-io","formatting","humanize","no-std","number-formatting","rust"],"created_at":"2026-06-25T15:01:44.265Z","updated_at":"2026-06-25T15:01:45.186Z","avatar_url":"https://github.com/trananhtung.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# numan\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\n[![Crates.io](https://img.shields.io/crates/v/numan.svg)](https://crates.io/crates/numan)\n[![Documentation](https://docs.rs/numan/badge.svg)](https://docs.rs/numan)\n[![CI](https://github.com/trananhtung/numan/actions/workflows/ci.yml/badge.svg)](https://github.com/trananhtung/numan/actions/workflows/ci.yml)\n[![License](https://img.shields.io/crates/l/numan.svg)](#license)\n[![no_std](https://img.shields.io/badge/no__std-yes-brightgreen.svg)](#no_std)\n\n**Humanize numbers in Rust** — turn raw numbers into the short, friendly strings\nyou see in dashboards, CLIs and reports, and parse them back.\n\n```rust\nassert_eq!(numan::compact(1_234),       \"1.2K\");\nassert_eq!(numan::word(1_200_000),      \"1.2 million\");\nassert_eq!(numan::metric(1_500),        \"1.5 k\");\nassert_eq!(numan::ordinal(22),          \"22nd\");\nassert_eq!(numan::parse(\"1.5M\").unwrap(), 1_500_000.0);\n```\n\nZero dependencies. `#![no_std]` (needs only `alloc`). One small, focused crate.\n\n## Why numan?\n\nRust's ecosystem already humanizes **file sizes**\n([`humansize`](https://crates.io/crates/humansize)) and **relative time**\n([`chrono-humanize`](https://crates.io/crates/chrono-humanize)). What was missing\nis the part Python's [`humanize`](https://github.com/jmoiron/humanize) and Go's\n[`go-humanize`](https://github.com/dustin/go-humanize) are famous for: shortening\nthe **magnitude of plain numbers**.\n\n| Need | Reach for |\n| --- | --- |\n| File sizes (`1.2 MiB`) | `humansize` |\n| Relative time (`3 hours ago`) | `chrono-humanize` |\n| Number → words (`forty-two`) | `num2words` |\n| Locale thousands grouping | `num-format` |\n| **Compact / word / metric magnitude (`1.2K`, `1.2 million`, `1.2 k`) + parsing** | **`numan`** ✅ |\n\n## Install\n\n```toml\n[dependencies]\nnuman = \"0.1\"\n```\n\n## Usage\n\n### Compact, word and metric notation\n\n```rust\nuse numan::{compact, word, metric};\n\nassert_eq!(compact(950),         \"950\");\nassert_eq!(compact(12_300),      \"12.3K\");\nassert_eq!(compact(1_500_000),   \"1.5M\");\nassert_eq!(compact(-2_000_000),  \"-2M\");\n\nassert_eq!(word(2_500),          \"2.5 thousand\");\nassert_eq!(word(1_000_000),      \"1 million\");\n\nassert_eq!(metric(1_000),        \"1 k\");   // SI: lowercase kilo\nassert_eq!(metric(2_200_000),    \"2.2 M\");\n```\n\n### Ordinals\n\n```rust\nassert_eq!(numan::ordinal(1),   \"1st\");\nassert_eq!(numan::ordinal(112), \"112th\");\n```\n\n### Parsing back\n\n```rust\nuse numan::parse;\n\nassert_eq!(parse(\"1.2K\").unwrap(),       1_200.0);\nassert_eq!(parse(\"1.5 million\").unwrap(), 1_500_000.0);\nassert_eq!(parse(\"-2.5bn\").unwrap(),     -2_500_000_000.0);\nassert_eq!(parse(\"1,234\").unwrap(),       1_234.0); // separators ignored\n```\n\nGreat for CLI flags like `--limit 1.5M`.\n\n### Fine-grained control with `Formatter`\n\n```rust\nuse numan::Formatter;\n\nlet f = Formatter::compact().precision(2).space(true);\nassert_eq!(f.format(1_234_567), \"1.23 M\");\n\n// Keep trailing zeros, force an explicit sign:\nlet f = Formatter::compact().trim_zeros(false).sign_plus(true);\nassert_eq!(f.format(1_000_000), \"+1.0M\");\n```\n\n| Builder method | Default | Effect |\n| --- | --- | --- |\n| `precision(n)` | `1` | Max fractional digits |\n| `trim_zeros(bool)` | `true` | Drop trailing `0`s and a dangling `.` |\n| `space(bool)` | per-notation | Space between number and suffix |\n| `sign_plus(bool)` | `false` | Prefix non-negatives with `+` |\n\n## Behavior notes\n\n- **Rounding** uses Rust's standard round-half-to-even, and correctly carries\n  into the next suffix (`compact(999_950)` → `\"1M\"`, never `\"1000K\"`).\n- **Beyond the table**, `compact` (above a trillion) falls back to scientific\n  notation (`compact(1e36)` → `\"1e36\"`), which still round-trips through `parse`.\n- **Non-finite** floats render as `\"NaN\"`, `\"inf\"`, `\"-inf\"`.\n- **Negative zero** (and negatives that round to zero) render as `\"0\"` — never `\"-0\"`.\n- In `parse`, `m`/`M` means **million** (compact convention), never SI *milli*;\n  SI *exa* (`E`) is not parsed, to avoid clashing with exponent notation (`1e3`),\n  so `metric` output at exa returns an error rather than a wrong value.\n\n## no_std\n\n`numan` is `#![no_std]` and only needs `alloc` (for `String`). It builds for\nbare-metal targets such as `thumbv7em-none-eabi`.\n\n## Contributors ✨\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the [emoji key](https://allcontributors.org/docs/en/emoji-key) for how each contribution is recognized, and open a PR or issue to get involved.\n\nThanks goes to these wonderful people:\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/trananhtung\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/30992229?v=4?s=100\" width=\"100px;\" alt=\"Tung Tran\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTung Tran\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/trananhtung/numan/commits?author=trananhtung\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#maintenance-trananhtung\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## License\n\nLicensed under either of [Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) at\nyour option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrananhtung%2Fnuman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrananhtung%2Fnuman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrananhtung%2Fnuman/lists"}