Skip to content

decimal

0.1.1Package record

Exact Arbitrary-Precision Decimal Vectors

0packages depend
836downloads / year
42.1%test coverage
13/13flavors OK

Overview

About

Arbitrary-precision vectors with an exact decimal representation, avoiding the rounding surprises of binary floating point. Built on the 'mpdecimal' C library, arithmetic is governed by an explicit decimal context controlling precision, rounding, and signaling, and vectors integrate with 'vctrs' for use in data frames, 'tibble' objects, summaries, and common numeric workflows. Missing values, signed zeros, infinities, and not-a-number values are supported throughout. The arithmetic model follows Cowlishaw (2009) "General Decimal Arithmetic" https://speleotrove.com/decimal/decarith.html.

Changes in 0.1.1
  • decimal vectors now convert to and from 'Arrow' decimal arrays directly. as_decimal() gained methods for Array and ChunkedArray. An Arrow decimal column of any width converts exactly, taking its scale from the Arrow type: Arrow's own decimal-to-string cast produces this package's canonical storage form once the exponent letter is folded to lowercase, so the strings need no re-parsing, and a property test guards that invariant. For 1,000,000 decimal128() values that takes 0.27s against 0.78s for casting to string and calling decimal(). Arrow integer columns convert exactly at every width, including int64 and uint64 values a double cannot hold. Other Arrow types convert through the ordinary as_decimal() rules for the equivalent R vector.
  • A decimal column now becomes an Arrow decimal field in arrow::arrow_table(), arrow::write_parquet() and arrow::write_dataset(). The field is an Arrow extension type whose storage is a real decimal128() or decimal256(), so Spark, DuckDB, pandas and other readers see a plain decimal column, while in R it returns as a decimal vector on every read path: as.data.frame(), arrow::read_parquet() and dplyr::collect() included. New arrow_decimal_type() pins a precision and scale for a column that will be appended to. Infinities and NaNs, which no Arrow decimal can represent, now raise an error on conversion instead of round-tripping through the 'vctrs' extension type; keep such a column as a string if you need them.
Show all changes in 0.1.1Hide the rest of the changes in 0.1.1
  • Arrow's compute engine does not operate on extension columns. For arrow-side arithmetic or filtering on a decimal column, write a plain field by passing a plain Arrow decimal type to arrow::as_arrow_array() or by setting options(decimal.arrow_extension = FALSE). A plain field comes back from arrow's own conversion as a double wearing the decimal class, because arrow reapplies the column's recorded R attributes; format() and as.character() now refuse such an object rather than print rounded values. New arrow_as_data_frame() converts an Arrow Table or RecordBatch to a data frame, reading plain decimal fields, including those in files written by other systems, as decimal vectors, and leaving every other column to arrow.
  • Fixed memory leaks on the error paths of the native kernels. An R error raised while an mpd_t was allocated abandoned it, because R's error handling unwinds past the code that would have freed it. Parsing an invalid decimal string leaked every handle the operation held, and an allocation failure part-way through setting up an operation leaked the handles already allocated. An R allocation failure while storing a result string leaked the formatted text too; that text is now released under R_UnwindProtect().
  • summary() now works on decimal vectors. It reports the same six statistics as [summary.default()] plus an NA's count, computed in decimal arithmetic and returned as a decimal vector, so figures that a double would round are preserved. Quartiles use the type 7 definition, matching stats::quantile().
  • Fixed is.na(), is.nan(), is.infinite(), is_qnan() and is_snan() returning malformed logical vectors. They forwarded mpdecimal's flag bits -- 4 for NaN, 8 for sNaN, 2 for Infinity -- instead of TRUE. The results printed correctly and compared equal with ==, but which() found no matching elements, sum() over-counted, and identical() was false against the obvious expectation.
  • DESCRIPTION now declares URL and BugReports, so the CRAN page links to the source repository and the issue tracker.
  • Building a decimal vector from character is substantially faster. The fractional-digit scan that decimal() performs on every element moved from R to C, which for 100,000 values takes construction from 1.13s to 0.05s when scale is supplied (about 22x) and from 2.28s to 0.05s when it is inferred (about 45x). Inferring the scale now costs the same as supplying it. This matters most when loading decimal data from 'Arrow' or a database, where the values arrive as a character vector in one call.
  • New vignette vignette("arrow-decimal-types"), covering lossless conversion between decimal vectors and Arrow's decimal128() / decimal256() types in both directions, including chunked arrays, Parquet columns, and the cases Arrow decimals cannot represent.
  • format() on a decimal vector now accepts the extra arguments that table printers pass to every column, such as digits, na.encode and justify from format.data.frame(), timezone from 'data.table' and trim from knitr::kable(), so decimal columns print inside a base data.frame, a data.table and a kable() table. The arguments are ignored rather than honored, so an exact value is never silently rounded for display. Arguments that would change how a number is written, such as nsmall, scientific and big.mark, are an error.
  • Fixed rbind() on data frames with decimal columns, which always failed with "Can't assign to elements past the end". Assigning past the end of a decimal vector now grows it with missing values, as it does a base vector, and binding columns of different scales takes the finer one. x[] <- value now replaces every element instead of failing.
  • match(), %in% and base merge() now compare decimal values rather than their stored text, so 2.5 matches 2.50, as == already said. Whole numbers still match integers and strings: decimal("20") %in% 20L stays TRUE.
  • New section in vignette("decimal-values") on decimal columns in a 'data.table': what works, and workarounds for the operations data.table runs on the stored text instead of the values, such as sorting and grouped min() and max().

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 3.0 min · r-devel-windows-x86_64
Status changes
  • OK13 OKNow
  • OK7 OK2026-08-25
Advisories

none known

Documentation

In release 0.1.1
READMEYes · 404 wordsVignettesYes · 3 · evaluation depends on the environmentNEWSYes · 100% structured · mentions 0.1.1Citation fileNoWebsiteYes · pkgdown
Help pages
31 (2 internal)includes a package overview page
Examples that run
100%29 run in a plain check (2 of them under a condition)
Exported functions with examples
100%
Documented parameters
91%
Return-value docs
100%
Help pages citing references
0%

Downloads

836
CRAN downloads in the past year
Rank #13,941 · ~2/day · ~70/mo
Daily download trend is not available in this view yet.
52630 days
83690 days
8361 year
Compare downloads with other packages →
Also on37 r2u6 autocran

Repository

3Stars
0Forks
3Open issues
1Open PRs
2Releases
68Commits
3Commit identities
68 commits · Last activity 2026-09-25 · Default branch at 0.1.1.9000, ahead of CRAN 0.1.1 (checked 2026-10-18)
Responsiveness
How these are sampled
PRs merged (all time)
94%
Median days to close, 50 most recently updated closed issues
not measured
Median days to close, 50 most recently updated closed PRs
0

Stars over time

2026-09-24 · 02026-09-30 · 3
PracticesBeta

7 development-tooling and community-health practices detected across 4 families in the upstream repository

Checks run against github.com/pedrobtz/decimal on 2026-10-18.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Docs source (3)
pkgdown

GitHub Pages site last deployed 2026-09-25 · The repository has a site deploy workflow

pkgdown site last built 2026-09-23

CRAN release process (1)
cran-comments.md
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-06-27
    Seen in the repository: CLAUDE.md
    Named in .Rbuildignore: .claude, CLAUDE.md
    Pull request it wrote: opened by a project member
    Commits: 1 by its own account · at least 36 crediting it in the message
Shared conventions any agent may read, so they name no particular tool.
Seen in the repository: .agents, AGENTS.md
Models named in its commits
  • Claude Opus 514 commits · Sep 2026
  • Claude Opus 5.514 commits · Sep 2026
  • Claude Fable 5.18 commits · Sep 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
13 external dependencies (excludes base and recommended)

Installing decimal adds 6 packages (4 with compiled code, 2.7 MB of source tarballs). Heaviest: vctrs 1.0 MB, rlang 766 KB, cli 629 KB.

Depends (1)
R >= 4.2.0
Imports (4)
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

People & History

People (2)
Author, Maintainer since 0.1.0 (2026), Copyright holder
Contributor, Copyright holder
Vendored 'mpdecimal' library in src/mpdecimal; see inst/COPYRIGHTS.
Releases (2)

Pick two releases to compare their code metrics.

  • 0.1.1Latest
    record
    2026-09-23 · current release · diff ↗ ·
    added 2 exports
    arrow_as_data_frame, arrow_decimal_type
  • 0.1.0
    record
    2026-08-24
  • R
    R 4.6.0 released · 2026-04-24

Package metadata

First published
2026-08-24
Total releases
2 / 1 yrs
License
MIT + file LICENSE OSI
Minimum R
≥ 4.2.0
Download size
197 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("decimal")
Baltazar, P., & Krah, S. (2026). decimal: Exact Arbitrary-Precision Decimal Vectors (Version 0.1.1) [Computer software]. https://doi.org/10.32614/CRAN.package.decimal

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for decimal version 0.1.1 [Data set]. HJJB, LLC. Data release v2026-10-21. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy