Skip to content

add primitive_fixed_point_decimal crate#1

Merged
BreezeWhite merged 1 commit intoBreezeWhite:mainfrom
WuBingzheng:main
Jun 25, 2025
Merged

add primitive_fixed_point_decimal crate#1
BreezeWhite merged 1 commit intoBreezeWhite:mainfrom
WuBingzheng:main

Conversation

@WuBingzheng
Copy link
Copy Markdown
Contributor

Although other decimal crates also claim to be fixed-point, they all bind the scale to each decimal instance, which changes during operations. They're more like decimal floating point. See the comparisonfor details.

While this primitive_fixed_point_decimal crate binds the scale to decimal type. The decimal types keep their scale for their whole lifetime instead of changing their scale during operations. It is real fixed-point decimal.

Although fixed-point is not suitable for this kind of mathematical calculations, it is still worth measuring the performance.

@BreezeWhite
Copy link
Copy Markdown
Owner

Wow, this looks so cool! Thanks for your contribution. I will update the benchmarks after merging this!

@BreezeWhite BreezeWhite merged commit b790cc4 into BreezeWhite:main Jun 25, 2025
@WuBingzheng
Copy link
Copy Markdown
Contributor Author

I have seen the updated README, but there are a few issues in it:

  1. The precision (Sig. Figs) is 38. The 35 in the code means the fraction part;
  2. The precision type is decimal;
  3. I run the benchmark on Mac/M1, and primitive_fixed_point_decimal is 2X faster than rust_decimal. What OS/Cpu did you run on?

@BreezeWhite
Copy link
Copy Markdown
Owner

  1. I am listing the correct Pi digits as you run the compiled binary will show.
  2. I will fix it.
  3. The spec is listed in README.

@WuBingzheng
Copy link
Copy Markdown
Contributor Author

I want to discuss the issue of Sig. Figs. again.

  1. Does this refer to the number of significant figures or the number of fraction places? This primitive_fixed_point_decimal type supports 38 significant figures, while the number of fraction places is specified by the app. For example, in this BBP algorithm, the intermediate results can exceed 100, so I allocated 3 of the 38 significant figures to the integer part and 35 to the fraction part. Judging by the name "Sig. Figs.", it should be significant figures, so it should be 38.

  2. Does this refer to the "capability of the crate" or the "the correct Pi digits(as you just said)"? If it's the latter, then big_decimal should be 1000, but not "arbitrary".

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.

2 participants