From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id F29632E06D for ; Tue, 21 May 2019 09:12:53 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BwvPJ2Y7qXAI for ; Tue, 21 May 2019 09:12:53 -0400 (EDT) Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A22602DD84 for ; Tue, 21 May 2019 09:12:53 -0400 (EDT) From: Serge Petrenko Subject: [tarantool-patches] [PATCH v2 0/2] Introduce decimal type to tarantool core. Date: Tue, 21 May 2019 16:12:37 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: georgy@tarantool.org, kostja@tarantool.org, Serge Petrenko https://github.com/tarantool/tarantool/issues/692 https://github.com/tarantool/tarantool/tree/sp/gh-692-introduce-decimal This patchset adds a new type, decimal fixed-point, to tarantool. The first patch adds decNumber library as a submodule. The second patch adds a small wrapper to the library to make it work with fixed-point decimal values, and adds a unit test. To evaluate number precision and scale from exponent and the amount of significant digits the following formulas are applied: If exponent < 0 then precision = MAX(digits, -exponent) and scale = -exponent If exponent > 0 then precision = digits + exponent, and scale = 0 Changes in v2: - get rid of explicit precision and scale, evaluate them from decNumber digits and exponent. - decimal is now an alias for decNumber - ln, log10, exp, sqrt, pow now accept precision to which the result should be rounded. Serge Petrenko (2): third-party: add decNumber library lib/core: introduce decimal type to tarantool .gitmodules | 3 + CMakeLists.txt | 7 + cmake/BuildDecNumber.cmake | 13 ++ src/CMakeLists.txt | 1 + src/lib/core/CMakeLists.txt | 3 +- src/lib/core/decimal.c | 293 ++++++++++++++++++++++++++++++++++++ src/lib/core/decimal.h | 159 +++++++++++++++++++ test/unit/CMakeLists.txt | 2 + test/unit/decimal.c | 168 +++++++++++++++++++++ test/unit/decimal.result | 51 +++++++ third_party/decNumber | 1 + 11 files changed, 700 insertions(+), 1 deletion(-) create mode 100644 cmake/BuildDecNumber.cmake create mode 100644 src/lib/core/decimal.c create mode 100644 src/lib/core/decimal.h create mode 100644 test/unit/decimal.c create mode 100644 test/unit/decimal.result create mode 160000 third_party/decNumber -- 2.20.1 (Apple Git-117)