{"id":20903330,"url":"https://github.com/boa-dev/ryu-js","last_synced_at":"2025-05-13T04:33:09.933Z","repository":{"id":43412024,"uuid":"278246003","full_name":"boa-dev/ryu-js","owner":"boa-dev","description":"Fast floating point to string conversion that complies to the ECMAScript number-to-string algorithm","archived":false,"fork":false,"pushed_at":"2025-02-24T21:44:07.000Z","size":1176,"stargazers_count":16,"open_issues_count":3,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-19T09:05:13.635Z","etag":null,"topics":["ecmascript","floating-point","formatting","hacktoberfest","rust","rust-crate","ryu"],"latest_commit_sha":null,"homepage":"","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/boa-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2020-07-09T02:47:38.000Z","updated_at":"2025-04-09T10:16:24.000Z","dependencies_parsed_at":"2025-04-18T23:25:38.797Z","dependency_job_id":"fdb536d7-0cef-45d9-be8a-a9d8b939b236","html_url":"https://github.com/boa-dev/ryu-js","commit_stats":{"total_commits":236,"total_committers":10,"mean_commits":23.6,"dds":"0.18644067796610164","last_synced_commit":"8659928b16c9ba60f785ce475845c23070a1394d"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boa-dev%2Fryu-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boa-dev%2Fryu-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boa-dev%2Fryu-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boa-dev%2Fryu-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boa-dev","download_url":"https://codeload.github.com/boa-dev/ryu-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251186236,"owners_count":21549408,"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":["ecmascript","floating-point","formatting","hacktoberfest","rust","rust-crate","ryu"],"created_at":"2024-11-18T13:12:34.152Z","updated_at":"2025-05-13T04:33:08.137Z","avatar_url":"https://github.com/boa-dev.png","language":"Rust","readme":"# Ryū-js\n\nRyū-js is a fork of the [ryu][ryu-crate] crate adjusted to comply to the ECMAScript [number-to-string][number-to-string] algorithm, also implementing [`Number.prototype.toFixed()`][number-to-fixed] compliant conversion.\n\n[ryu-crate]: https://crates.io/crates/ryu\n[number-to-string]: https://tc39.es/ecma262/#sec-numeric-types-number-tostring\n[number-to-fixed]: https://tc39.es/ecma262/#sec-number.prototype.tofixed\n\nPure Rust implementation of Ryū, an algorithm to quickly convert floating point\nnumbers to decimal strings.\n\nThe PLDI'18 paper [*Ryū: fast float-to-string conversion*][paper] by Ulf Adams\nincludes a complete correctness proof of the algorithm. The paper is available\nunder the creative commons CC-BY-SA license.\n\nThis Rust implementation is a line-by-line port of Ulf Adams' implementation in\nC, [https://github.com/ulfjack/ryu][upstream].\n\n*Requirements: This crate supports any compiler version back to rustc 1.64; it\nuses nothing from the Rust standard library so is usable from no_std crates.*\n\n[paper]: https://dl.acm.org/citation.cfm?id=3192369\n[upstream]: https://github.com/ulfjack/ryu/tree/abf76d252bc97300354857e64e80d4a2bf664291\n\n```toml\n[dependencies]\nryu-js = \"1.0\"\n```\n\n\u003cbr\u003e\n\n## Example\n\n```rust\nfn main() {\n    let mut buffer = ryu_js::Buffer::new();\n    let printed = buffer.format(1.234);\n    assert_eq!(printed, \"1.234\");\n}\n```\n\n## Performance \n\n\u003c!--\n\n## Performance (lower is better)\n\n![performance](https://raw.githubusercontent.com/boa-dev/ryu-js/master/performance.png)\n\n--\u003e\n\nYou can run upstream's benchmarks with:\n\n```console\n$ git clone https://github.com/ulfjack/ryu c-ryu\n$ cd c-ryu\n$ bazel run -c opt //ryu/benchmark:ryu_benchmark\n```\n\nAnd the same benchmark against our implementation with:\n\n```console\n$ git clone https://github.com/boa-dev/ryu-js rust-ryu\n$ cd rust-ryu\n$ cargo run --example upstream_benchmark --release\n```\n\nThe benchmarks measure the average time to print a 32-bit float and average\ntime to print a 64-bit float, where the inputs are distributed as uniform random\nbit patterns 32 and 64 bits wide.\n\nThe upstream C code, the unsafe direct Rust port, and the safe pretty Rust API\nall perform the same, taking around 21 nanoseconds to format a 32-bit float and\n31 nanoseconds to format a 64-bit float.\n\nThere is also a Rust-specific benchmark comparing this implementation to the\nstandard library which you can run with:\n\n```console\n$ cargo bench\n```\n\nThe benchmark shows Ryū approximately 2-5x faster than the standard library\nacross a range of f32 and f64 inputs. Measurements are in nanoseconds per\niteration; smaller is better.\n\n## Formatting\n\nThis library tends to produce more human-readable output than the standard\nlibrary's to\\_string, which never uses scientific notation. Here are two\nexamples:\n\n- *ryu:* 1.23e40, *std:* 12300000000000000000000000000000000000000\n- *ryu:* 1.23e-40, *std:* 0.000000000000000000000000000000000000000123\n\nBoth libraries print short decimals such as 0.0000123 without scientific\nnotation.\n\n\u003cbr\u003e\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-BOOST\"\u003eBoost Software License 1.0\u003c/a\u003e at your\noption.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboa-dev%2Fryu-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboa-dev%2Fryu-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboa-dev%2Fryu-js/lists"}