{"id":16572084,"url":"https://github.com/eddelbuettel/rcppint64","last_synced_at":"2025-06-28T07:35:54.326Z","repository":{"id":189527526,"uuid":"679493373","full_name":"eddelbuettel/RcppInt64","owner":"eddelbuettel","description":"Rcpp-based helper functions to transfer int64 and nanotime values back and forth","archived":false,"fork":false,"pushed_at":"2025-01-20T13:45:35.000Z","size":67,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-27T12:46:27.953Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eddelbuettel.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-08-17T01:20:57.000Z","updated_at":"2025-01-20T13:45:36.000Z","dependencies_parsed_at":"2024-06-11T17:04:06.820Z","dependency_job_id":"cccf09d4-c05a-4f77-ad5d-6285b3b7c8a2","html_url":"https://github.com/eddelbuettel/RcppInt64","commit_stats":null,"previous_names":["eddelbuettel/rcppint64"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eddelbuettel/RcppInt64","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2FRcppInt64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2FRcppInt64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2FRcppInt64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2FRcppInt64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddelbuettel","download_url":"https://codeload.github.com/eddelbuettel/RcppInt64/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2FRcppInt64/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262393511,"owners_count":23304132,"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-10-11T21:26:17.914Z","updated_at":"2025-06-28T07:35:54.302Z","avatar_url":"https://github.com/eddelbuettel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## RcppInt64: Passing integer64 and nanotime To And From C++\n\n[![CI](https://github.com/eddelbuettel/RcppInt64/actions/workflows/r2u.yaml/badge.svg)](https://github.com/eddelbuettel/RcppInt64/actions/workflows/r2u.yaml)\n[![License](https://eddelbuettel.github.io/badges/GPL2+.svg)](https://www.gnu.org/licenses/gpl-2.0.html)\n[![CRAN](https://www.r-pkg.org/badges/version/RcppInt64)](https://cran.r-project.org/package=RcppInt64)\n[![r-universe](https://eddelbuettel.r-universe.dev/badges/RcppInt64)](https://eddelbuettel.r-universe.dev/RcppInt64)\n[![Dependencies](https://tinyverse.netlify.app/badge/RcppInt64)](https://cran.r-project.org/package=RcppInt64)\n[![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/rcppint64)](https://github.com/eddelbuettel/rcppint64)\n\n### Motivation\n\nWhile R has no _native_ support for 64-bit integer values, the [`bit64`\npackage](https://cran.r-project.org/package=bit64) by Jens Oehlschlägel is widely used to fill this\ngap by (very carefully) passing the bitmaps of `int64_t` values around in `double`.  This works on\nthe R side by virtue of a S3 class `integer64` with proper dispatching, and on the C/C++ side where\nthe values can be past by `memcpy`.  What one cannot do is simply copying or casting: the tradeoff\nmade in representing a `double` with as large a range is that the 'delta' between values is not\nconstant acros the range and naive casting between both representation *will* be lossy and distort\nvalues.\n\nThis package contains helper functions that were previously appearing in helper header files in\ndifferent packages, and reorganizes them along with a proper unit tests.  The key header file\nprovided here can be included directly. Function to assert `integer64` source, convert to and from\nin both scalar and vector cases as well as a pair of `as\u003c\u003e()` and `wrap()` converters are provided.\n\nAs our [nanotime package](https://github.com/eddelbuettel/nanotime) builds on the same `integer64`\ninfrastructure, its bi-directional conversions between R and C++ are also supported.\n\n## Examples\n\n### Int64\n\nThe example for the included demonstration function show how a vector of\n`integer64` values (here spanning the power of 10 ranging from 0 to 18)\ncan be received in C++, altered (where we just add one) and returned, all\nwhile maintaining `integer64` aka `int64_t` type.\n\n```r\n\u003e example(Int64toInt64)\n\nI64I64\u003e # generate all powers of 10 fro 0 .. 18\nI64I64\u003e v \u003c- bit64::as.integer64(10^seq(0,18))\n\nI64I64\u003e # pass them to function which will add one to each, print  and return\nI64I64\u003e Int64toInt64(v)\n2\n11\n101\n1001\n10001\n100001\n1000001\n10000001\n100000001\n1000000001\n10000000001\n100000000001\n1000000000001\n10000000000001\n100000000000001\n1000000000000001\n10000000000000001\n100000000000000001\n1000000000000000001\ninteger64\n [1] 2                   11                  101\n [4] 1001                10001               100001\n [7] 1000001             10000001            100000001\n[10] 1000000001          10000000001         100000000001\n[13] 1000000000001       10000000000001      100000000000001\n[16] 1000000000000001    10000000000000001   100000000000000001\n[19] 1000000000000000001\n\u003e\n```\n\n### Nanotime\n\nSimilarly, we can instantiate a vector of `nanotime` values and increment, show, and return its\nvalues.\n\n```r\n\u003e example(NanotimeToNanotime)\n\nNntmTN\u003e # generate all powers of 10 fro 0 .. 18\nNntmTN\u003e if (requireNamespace(\"nanotime\", quietly=TRUE)) {\nNntmTN+     v \u003c- nanotime::as.nanotime(10^seq(0,18))\nNntmTN+     # pass them to function which will add one to each, print  and return\nNntmTN+     NanotimeToNanotime(v)\nNntmTN+ }\n2\n11\n101\n1001\n10001\n100001\n1000001\n10000001\n100000001\n1000000001\n10000000001\n100000000001\n1000000000001\n10000000000001\n100000000000001\n1000000000000001\n10000000000000001\n100000000000000001\n1000000000000000001\n [1] 1970-01-01T00:00:00.000000002+00:00 1970-01-01T00:00:00.000000011+00:00\n [3] 1970-01-01T00:00:00.000000101+00:00 1970-01-01T00:00:00.000001001+00:00\n [5] 1970-01-01T00:00:00.000010001+00:00 1970-01-01T00:00:00.000100001+00:00\n [7] 1970-01-01T00:00:00.001000001+00:00 1970-01-01T00:00:00.010000001+00:00\n [9] 1970-01-01T00:00:00.100000001+00:00 1970-01-01T00:00:01.000000001+00:00\n[11] 1970-01-01T00:00:10.000000001+00:00 1970-01-01T00:01:40.000000001+00:00\n[13] 1970-01-01T00:16:40.000000001+00:00 1970-01-01T02:46:40.000000001+00:00\n[15] 1970-01-02T03:46:40.000000001+00:00 1970-01-12T13:46:40.000000001+00:00\n[17] 1970-04-26T17:46:40.000000001+00:00 1973-03-03T09:46:40.000000001+00:00\n[19] 2001-09-09T01:46:40.000000001+00:00\n\u003e\n```\n\n### Installation\n\nThe package is available via [CRAN](https://cran.r-project.org) and can be installed the usual way\nvia `install.packages(\"RcppInt64\")`.\n\n### Contributing\n\nAny problems, bug reports, or features requests for the package can be submitted and handled most\nconveniently as [Github issues](https://github.com/eddelbuettel/rcppint64/issues) in the\nrepository.\n\nBefore submitting pull requests, it is frequently preferable to first discuss need and scope in such\nan issue ticket.  See the file\n[Contributing.md](https://github.com/RcppCore/Rcpp/blob/master/Contributing.md) (in the\n[Rcpp](https://github.com/RcppCore/Rcpp) repo) for a brief discussion.\n\n### Author\n\nDirk Eddelbuettel\n\n### License\n\nGPL (\u003e= 2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Frcppint64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddelbuettel%2Frcppint64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Frcppint64/lists"}