Adds truncate, half-up rounding functions
This is an alternative approach to allowing the user to specify a mode for a closure, namely, providing two specific and commonly used rounding functions in a quantize-like interface.
This commit adds
- A binding to the
decContextSetRoundingfunction - A d128 method,
with_roundingto initialize aContextwith a givenRounding ROUND_DOWNandHALF_UPthread local staticContexts initialized with those roundings- Two methods on d128,
with_round_downandwith_half_upthat mimicwith_contextbut use alternative roundings - Two methods,
truncateandroundthat offerquantizelike interfaces to these rounding settings.
@jonathanstrong do you want to make this merge cleanly so that it can be merged? Then we can push a new version out.
you're interested in the code that fixes the uninitialized usage, correct? happy to setup a clean pull request with those changes if so.
I think we can merge the whole thing. I also sent you an invite to commit directly if that helps.
Are you sure? There are quite a few unrelated differences, including a d64 type, some From and TryFrom conversion routines that should probably be reviewed, some dependencies brought in for benchmarking that are probably not a good idea to include in the upstream repo, etc.
If you are happy to do it in smaller steps that would be even better.
ok, I pushed a branch to upstream (i.e. this repo) as I am now a collaborator (thank you). it is only the MaybeUninit conversion changes: https://github.com/alkis/decimal/compare/uninit-fix. next week I can setup pull requests for the other things. if you have the bandwidth it'd be nice to get a second set of eyes on the changes (the stuff other than MaybeUninit). I am pretty good at rust but not experienced at C.
Will do. Thanks @jonathanstrong!