Add conversion between `box_decimal_t` and scaled integer
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
These are functions to convert between box_decimal_t and integers with
scale. Scale is a negated exponent. For example decimal 1.23 will be
converted to integer 123 if scale is 2 and to 1230 if scale is 3.
For API details check comments for next functions in
src/box/decimal.h.
API_EXPORT box_decimal_t *
box_decimal_scale_from_int32(box_decimal_t *dec, int32_t value, int scale);
API_EXPORT box_decimal_t *
box_decimal_scale_from_int64(box_decimal_t *dec, int64_t value, int scale);
API_EXPORT box_decimal_t *
box_decimal_scale_from_int128(box_decimal_t *dec, const uint64_t *value,
int scale);
API_EXPORT box_decimal_t *
box_decimal_scale_from_int256(box_decimal_t *dec, const uint64_t *value,
int scale);
API_EXPORT const box_decimal_t *
box_decimal_scale_to_int32(const box_decimal_t *dec, int scale, int32_t *value);
API_EXPORT const box_decimal_t *
box_decimal_scale_to_int64(const box_decimal_t *dec, int scale, int64_t *value);
API_EXPORT const box_decimal_t *
box_decimal_scale_to_int128(const box_decimal_t *dec, int scale,
uint64_t *value);
API_EXPORT const box_decimal_t *
box_decimal_scale_to_int256(const box_decimal_t *dec, int scale,
uint64_t *value);
Requested by @nshy in https://github.com/tarantool/tarantool/commit/922eb0ce08e6382a6931cd74dd2384c61d5ee6cb.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the comments for the listed functions in src/box/decimal.h and compare their signatures with existing documentation in this repository. Document the int32, int64, int128, and int256 conversions, including the negated-exponent scale behavior and both directions; done when all eight APIs and the 1.23 example are clearly covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100