Giter Site home page Giter Site logo

zig_decimal's Introduction

zig_Decimal

update zig 0.13.0


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

[https://github.com/dnotq/decNumber](https://github.com/dnotq/decNumber)

---
**os linux**
**I don't have Windows or Macintosh but it should work **

  [https://www.bytereef.org/mpdecimal/index.html](https://www.bytereef.org/mpdecimal/index.html)

const c = @cImport( { @cInclude("mpdecimal.h"); } );

installation with your package manager or download

validated: by https://speleotrove.com/decimal/

official site thank you for making this standardization available

---
→ 2023-02-27 add compare a, b = enum CMP. LT EQ LT
→ 2023-03-02 add ceil r = a
→ 2023-03-02 add rem r = a / b
→ 2023-03-02 result alignment with OS400
→ 2023-03-02 update debugPrint(cnbr: DCMLFX, txt : []const u8)
→ 2023-03-27 isOverfow -> isOverflow
→ 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

    associated function:

    def: checks the relevance of bounding with mpdecimal and determines the fixed decimal
    Test if the context is active otherwise it calls openContext()
        free: frees the associated memory storage ".number" (not the definition)

    debugPrint: small followed by ".number"

    isNumber: check value is compliant '0-9 + - .' compliant SQL postgres DB2...

    isValide: uses isNumber, and checks if the external value complies with the boundary

    isOverflow: check if the internal value is out of bounds

    assign: give a value (text format) to ".number"

    setZeros: forces the value 0 to ".number"

    isZeros: checks if the value 0

    round: two-function round and truncate (0.5 = +1) see finance...

    trunc: to a function, truncate without rounding

    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)

    add: a = a + b

    sub: a = a - b

    mul: a = a x b

    div: a = a / b if b = zeros raises an error

    addTo: r = a + b

    subTo: r = a - b

    mulTo: r = a x b

    divto: r = a / b if b = zeros raises an error

    floor: r = a

    ceil : r = a

    rem : r = a / b if b = zeros raises an error

    rate: raises a value with the percentage ex ( n = (val x nbr) , val = (n x %1.25)

   

    function off DCMLF

    enum CMP LT EQ GT

    cmp compare a ,b return CMP

    mdrate module: returns ex: ttc , htx (base val, article nrb, rate = 25 ) practice in 5 operations

    forceAssign: forces the value

    dsperr: practical @panic product in test

    debugContext: print context

   ← 2024-03-23 update change var const ...

zig_decimal's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.