Introduce fixed point decimals
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
Part of https://github.com/tarantool/tarantool-ee/issues/1188
Task: https://jira.vk.team/browse/TNTP-2277
Product: Tarantool
Since: 3.5.0
Root document:
- https://www.tarantool.io/en/doc/latest/platform/engines/
- https://www.tarantool.io/ru/doc/latest/reference/reference_lua/decimal/
SME: @ nshy @ sergepetrenko
- Новые типы, decimal32/64/... появились во всех движках, не только memcs (memtx и vinyl)
- Это затрагивает модуль decimal
Added support for fixed point decimal types decimal32, decimal64,
decimal128 and decimal256. They differ in number of significant
decimal digits:
decimal32- 9decimal64- 18decimal128- 38decimal256- 76
These types also has additional parameter scale which defines the
position of decimal point or it can be seen as implied decimal exponent
with value of -scale. For example type decimal32 with scale = 4
can represent values from -99999.9999 to 99999.9999. And decimal
with scale = -2 can represent values from -999999999 * 10^2 to
999999999 * 10^2.
Example 1. Creating space with field of fixed decimal type.
s = box.schema.create_space('test', {format = {
{'a', 'unsigned'}, {'b', 'decimal32', scale = 4},
}})
Decimal values can be created using decimal module. It changed to
be able to represent values of new types:
- limitation on exponent is removed
- precision is increased to 76 decimal digits
- printing is done in scientific notation
Example 2. Passing decimal values.
local decimal = require('decimal')
s = box.schema.create_space('test', {format = {
{'a', 'unsigned'}, {'b', 'decimal32', scale = 4},
}})
s:create_index('pk')
s:insert({1, decimal.new(13333)})
s:insert({2, decimal.new(0.0017)})
Requested by @nshy in https://github.com/tarantool/tarantool/commit/92b310215c70f0c7bf70abd64c33c2cb012965bb.
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 linked engines documentation and the Lua decimal reference, using the Tarantool 3.5.0 context and the supplied examples as the scope. Update the documentation to cover decimal32, decimal64, decimal128, and decimal256, their scale ranges, and the decimal module changes; done means the new fixed-point behavior is documented consistently in the referenced English and Russian material.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100