Skip to content

Add FixedPointDecimals package extension for FixedDecimal → Dec128 BSON representation#42

Merged
ancapdev merged 3 commits into
masterfrom
copilot/add-package-extension-fixeddecimal
Mar 31, 2026
Merged

Add FixedPointDecimals package extension for FixedDecimal → Dec128 BSON representation#42
ancapdev merged 3 commits into
masterfrom
copilot/add-package-extension-fixeddecimal

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

FixedDecimal types from FixedPointDecimals.jl had no BSON representation, requiring manual conversion. This adds a weak dependency extension that maps FixedDecimal{T,f} to BSON decimal128 via Dec128, using precise decimal arithmetic throughout.

Changes

  • ext/LightBSONFixedPointDecimalsExt.jl — new package extension (loaded only when FixedPointDecimals.jl is present):

    • bson_representation_type(FixedDecimal{T,f}) = Dec128
    • Forward: Dec128(x.i, -f) — exact conversion using raw integer coefficient and scale
    • Reverse: reinterpret(FixedDecimal{T,f}, T(x * Dec128(1, f))) — reconstructs the raw integer via decimal-only arithmetic, avoiding binary float precision loss
  • Project.toml — adds FixedPointDecimals as a weak dependency with compat "0.5, 0.6", registers the extension, bumps julia compat to "1.9" (minimum for package extensions), and adds FixedPointDecimals to test extras/targets

  • test/fixed_decimal_tests.jl — roundtrip tests for multiple scale factors; confirms conversion is bit-exact

Usage

using LightBSON, FixedPointDecimals, DecFP

x = FixedDecimal{Int64, 2}(1.23)  # internal: i=123, f=2

buf = UInt8[]
writer = BSONWriter(buf)
writer["x"] = x          # stored as Dec128("1.23") via Dec128(123, -2)
close(writer)

BSONReader(buf)["x"][FixedDecimal{Int64, 2}]  # == 1.23, exact roundtrip

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/FluxML/MacroTools.jl/tarball/1e0228a030642014fe5cfe68c2c0a818f9e3f522
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaArrays/StaticArraysCore.jl/tarball/6ab403037779dae8c514bad259f32a447262455a
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaArrays/UnsafeArrays.jl/tarball/c63023bd84f46f9df786c90180d4f79dbfdafa2a
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaBinaryWrappers/DecFP_jll.jl/tarball/40e4404a0a267a8e75f5c1ce2cc9b5e2ce1ba268
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaBinaryWrappers/OpenSpecFun_jll.jl/tarball/1346c9208249809840c91b26703912dff463d335
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaCollections/DataStructures.jl/tarball/e86f4a2805f7f19bec5129bc9150c38208e5dc23
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaCollections/OrderedCollections.jl/tarball/05868e21324cede2207c6f0f466b4bfef6d5e7ee
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaData/DataAPI.jl/tarball/abe83f3a2f1b857aac70ef8b269080af17764bbe
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaData/Parsers.jl/tarball/7d2f8f21da5db6a806faf7b9b292296da42b2810
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaData/StructTypes.jl/tarball/159331b30e94d7b11379037feeb9b690950cace8
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaData/Tables.jl/tarball/f2c1efbc8f3a609aadf318094f8fc5204bdaf344
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaData/WeakRefStrings.jl/tarball/b1be2855ed9ed8eac54e5caff2afcdb442d52c23
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaDocs/DocStringExtensions.jl/tarball/7442a5dfe1ebb773c29cc2962a8980f47221d76c
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaFolds/InitialValues.jl/tarball/4da0f88e9a39111c2fa3add390ab15f3a44f3ca3
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaFolds/SplittablesBase.jl/tarball/e08a62abc517eb79667d0a29dc08a3b589516bb5
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaFolds2/BangBang.jl/tarball/cceb62468025be98d42a5dc581b163c20896b040
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaFolds2/MicroCollections.jl/tarball/44d32db644e84c75dab479f1bc15ee76a1a3618f
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaFolds2/Transducers.jl/tarball/4aa1fdf6c1da74661f6f5d3edfd96648321dade9
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaFunctional/CompositionsBase.jl/tarball/802bb88cd69dfd1509f6670416bd4434015693ad
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaLang/PrecompileTools.jl/tarball/07a921781cab75691315adc645096ed5e370cb77
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaMath/DecFP.jl/tarball/3b98337b5b709548754973b9d79f4d5f2038c7cf
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaMath/FixedPointDecimals.jl/tarball/41d3a5de0eab320cc04833a373f0fcb3640073d5
    • Triggering command: /usr/bin/julia julia -e using Pkg; Pkg.add("FixedPointDecimals") (http block)
  • https://api.github.com/repos/JuliaMath/InverseFunctions.jl/tarball/a779299d77cd080bf77b97535acecd73e1c5e5cb
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaMath/IrrationalConstants.jl/tarball/b2d91fe939cae05960e760110b328288867b5758
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaMath/SpecialFunctions.jl/tarball/2700b235561b0335d5bef7097a111dc513b8655e
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaObjects/Accessors.jl/tarball/2eeb2c9bef11013efc6f8f97f32ee59b146b09fb
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaObjects/ConstructionBase.jl/tarball/b4b092499347b18a015186eae3042f72267106cb
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaPackaging/JLLWrappers.jl/tarball/0533e564aae234aff59ab625543145446d8b6ec2
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaPackaging/Preferences.jl/tarball/8b770b60760d4451834fe79dd483e318eee709c4
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaStats/LogExpFunctions.jl/tarball/13ca9e2586b89836fd20cccf56e57e2b9ae7f38f
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/JuliaStrings/InlineStrings.jl/tarball/8f3d257792a522b4601c24a577954b0a8cd7334d
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/ancapdev/FNVHash.jl/tarball/d6de2c735a8bffce9bc481942dfa453cc815357e
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/jw3126/ArgCheck.jl/tarball/f9e9a66c9b7be1ad7372bbd9b062d9230c30c5ce
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/jw3126/Setfield.jl/tarball/c5391c6ace3bc430ca630251d02ea9687169ca68
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/queryverse/DataValueInterfaces.jl/tarball/bfc1187b79289637fa0ef6d4436ebdfe6905cbd6
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/queryverse/IteratorInterfaceExtensions.jl/tarball/a3f24677c21f5bbe9d2a714f95dcd58337fb2856
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/queryverse/TableTraits.jl/tarball/c06b2f539df1c6efa794486abfb6ed2022561a39
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/quinnj/JSON3.jl/tarball/411eccfe8aba0814ffa0fdf4860913ed09c34975
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/rfourquet/BitIntegers.jl/tarball/091d591a060e43df1dd35faab3ca284925c48e46
    • Triggering command: /usr/bin/julia julia -e using Pkg; Pkg.add("FixedPointDecimals") (http block)
  • https://api.github.com/repos/tkf/Baselet.jl/tarball/aebf55e6d7795e02ca500a689d326ac979aaf89e
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • https://api.github.com/repos/tkf/DefineSingletons.jl/tarball/0fba8b706d0178b4dc7fd44a96a92382c9065c2c
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (http block)
  • pkg.julialang.org
    • Triggering command: /usr/bin/julia julia --project -e import Pkg; Pkg.instantiate() (dns block)
    • Triggering command: /usr/bin/julia julia -e using Pkg; Pkg.add("FixedPointDecimals") (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add package extension for FixedDecimal types Add FixedPointDecimals package extension for FixedDecimal → Dec128 BSON representation Mar 31, 2026
Copilot AI requested a review from ancapdev March 31, 2026 18:01
@ancapdev ancapdev marked this pull request as ready for review March 31, 2026 19:37
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 31, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (6173a7b) to head (e700c7b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
+ Coverage   90.08%   90.12%   +0.03%     
==========================================
  Files          13       14       +1     
  Lines         787      790       +3     
==========================================
+ Hits          709      712       +3     
  Misses         78       78              
Flag Coverage Δ
unittest 90.12% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread Project.toml Outdated
@ancapdev ancapdev merged commit c99cc7f into master Mar 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants