decimal
decimal copied to clipboard
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
decContextSetRounding
function - A d128 method,
with_rounding
to initialize aContext
with a givenRounding
-
ROUND_DOWN
andHALF_UP
thread local staticContext
s initialized with those roundings - Two methods on d128,
with_round_down
andwith_half_up
that mimicwith_context
but use alternative roundings - Two methods,
truncate
andround
that offerquantize
like 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!