Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/as400jplpc/zig_decimal
processing decimal numbers with mpdecimal as a backdrop
https://github.com/as400jplpc/zig_decimal
decimal gestion zig
Last synced: 19 days ago
JSON representation
processing decimal numbers with mpdecimal as a backdrop
- Host: GitHub
- URL: https://github.com/as400jplpc/zig_decimal
- Owner: AS400JPLPC
- Created: 2023-02-25T20:12:47.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-17T23:06:42.000Z (about 2 months ago)
- Last Synced: 2024-12-18T00:19:13.730Z (about 2 months ago)
- Topics: decimal, gestion, zig
- Language: C++
- Homepage:
- Size: 11.7 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zig_Decimal
processing decimal numbers with mpdecimal as a backdrop
***I wrote this lib to free myself from arithmetic problems on large decimals***
[https://speleotrove.com/decimal/](https://speleotrove.com/decimal/)
This part explains why we need it.
Another source that inspired me and that joins what I think 1990
[https://github.com/dnotq/decNumber](https://github.com/dnotq/decNumber)
---
[https://www.bytereef.org/mpdecimal/index.html](https://www.bytereef.org/mpdecimal/index.html)
Include("mpdecimal.h) view build;
you need to mount the mpdecimal package in your system
installation with your package manager or download
validated: by https://speleotrove.com/decimal/
official site thank you for making this standardization available
---→ 2023-03-27 test decimal 256 - 70 digit and 512 - 142 digit work bank international
CTX_ADDR Communication structure for default common control decimal128 -> MPD_ROUND_HALF_EVEN
openContex() :
it is possible, to have very very large numbers
disable c.mpd_ieee_context but you go out of the norm
DCMLFX includes 3 values
number: mpdecimal structure [*c]
integer: number of integers in front of the point
scale: number of integers behind the point
string: if the scale part is larger than its definition,
it rounds then adds zeros if necessary
(respects the SQL display alignment standard on the left ex: 1.00)
rate: raises a value with the percentage ex ( n = (val x nbr) , val = (n x %1.25)
|Function | Description | Pub |
|--------------|------------------------------------------------------|-----|
|openContex | Creates icontext internal lib mpdecimal | |
|init | Creates Decimal (E,tier , Scal) | x |
|deinit | De-allocates the Decimal | x |
| | | |
|isActif | check the area is still active | x |
|isNumber | check value is compliant '0-9 + - .' | |
|isValide | control number and validity normalize | x |
|isOverflow | check if the internal value is out of bounds | x |
[setDcml | give a value (text format) to ".number" | x |
|setZero | forces the value 0 to ".number" | x |
|isZeros | checks if the value 0 | x [
|round | two-function round and truncate see finance... | x |
|trunc | to a function, truncate without rounding | x |
|string | format area if the scale part is larger,it rounds | x |
| | | |
|add | a = a + b a.add(b) | x |
|sub | a = a - b | x |
|mult | a = a * b | x |
|div | a = a / b if b = zeros raises an error | x |
|addTo | r = a + b r.addto(a,b) | x |
|subTo | r = a - b | x |
|multTo | r = a * b | x |
|divTo | r = a / b if b = zeros raises an error | x |
|floor | r = a | x |
|ceil | r = a | x |
|rem | r = a / b if b = zeros raises an error | x |
|rate | total.rate(prix,nbritem,tax) | x |
|cmp | compare a , b returns EQ LT GT | x |
| | | |
|dsperr | practical @panic product in test | x |
[debugContext | displlay context value internal mpdecimal | x [
|debugPrint | small followed by ".number" | x |
| | | x |
|Dcmliterator | Struct Iterator | x |
|next | next iterator Char(UTF8) | x |
|preview | preview iterator Char(UTF8) | x |
|iterator | Returns a StringIterator over the String | x |
|isUTF8Byte | Checks if byte is part of UTF-8 character | . |
|getIndex | Returns the real index of a unicode | . |
|getUTF8Size | Returns the UTF-8 character's size | . |
sp; ← 2024-12-17 **I have completed the checks and memory leak tests, the functions are reviewed and corrected with the consideration.**
→ 2024-12-23 03:13
Big is working on memory leaks.
Now I think it's fixed.
→ 2024-12-19 The build in the library as well as in src-zig is compliant and without redundancy.