KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
libdeci
★ 8
Open GitHub ↗
Big decimal library for C
Download README (.md)
Explore Similar Repositories
SpatialCrowdsourcing-TOBM
:
Two-sided online bipartite matching in spatial data: experiments and analysis
election-prediction
:
No description available.
FA2Copy
:
An extension for Final Alert 2
mp3-stream-title
:
A lightweight PHP library to fetch currently playing tracks from online radio streams.
invoice_scanner
:
Simple OCR on device app with Firebase ML Kit
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
libdeci
?
Download (.md)
**libdeci** is a big-decimal arithmetics library for C. [](https://travis-ci.org/shdown/libdeci) Features: * supports GNU GCC, Clang, ICC, MSVC; * does not require extra memory for any operation, thus never allocates memory; * compiles as both C and C++; * hardware-independent ([it even works on WebAssembly](https://shdown.github.io/deci/demo.html)); * simple; * fast; * well-tested. # Simplicity, performance and algorithms In libdeci, only the “basecase” (quadratic) algorithms are implemented for multiplication, division and conversion to/from binary. There are multiple reasons for that: * In the world of arbitrary-precision arithmetic especially, fancy algorithms are slow when N is small, thus any reasonable implementation that employs them tends to fall back to dumb quadratic algorithms if N is less than some threshold. It is for this reason, combined with the fact that many of the fancy algorithms are divide-and-conquer in nature, the dumb algorithms are also called “basecase” algorithms. So even if you need to use a fancy algorithm to crunch very large decimal numbers, you will still need the “basecase” algorithms. * If you are crunching very large *decimal* numbers with fancy algorithms, most likely you are doing something wrong: binary arithmetics is native for computers, so consider using [GMP](https://gmplib.org/) in the first place; or, alternatively, convert “to bits” before doing costly computation, and convert the result back afterwards. * Fancy algorithms introduce complexity. * Fancy algorithms allocate extra memory. ## But still, what’s your plan? * For multiplication, we have: - [libdeci-kara](https://github.com/shdown/libdeci-kara) that implements intermediate-fanciness multiplication via Karatsuba algorithm; - [libdeci-ntt](https://github.com/shdown/libdeci-ntt) that implements high-fanciness multiplication via the number-theoretic transform (variant of Fourier transform). * For division, we have [libdeci-newt](https://github.com/shdown/libdeci-newt). It implements fancy division via Newton’s method. Note that it requires that a fast (sub-quadratic) multiplication routine be passed as a callback. Use either [libdeci-kara](https://github.com/shdown/libdeci-kara) or [libdeci-ntt](https://github.com/shdown/libdeci-ntt) for that. * [Divide-and-conquer algorithms](http://www.numberworld.org/y-cruncher/internals/radix-conversion.html) for decimal-to-binary and binary-to-decimal radix conversion. Note that in order to use those to convert *to* binary, you need to be able to multiply big binary numbers; and in order to convert *from* binary, you need to be able to divide big binary numbers. We recommend using [GMP](https://gmplib.org/) for that (more specifically, the [low-level functions](https://gmplib.org/manual/Low_002dlevel-Functions) operating directly on `mp_limb_t` spans).