Comments (9)
can use wide-decimal type how a integer type?
Hi Daniel. Thank you for your query.
Unfortunately, I would not generally recommend using wide-decimal (i.e., decwide-t
) as an integer type. You can perform some floating-point decimal calculations and convert the results to integer. But wide-decimal is not really intended nor tested to be an integer representation.
You can do pure signed/unsigned integer calculations with my other repository wide-integer. But there is at the moment no inter-conversion between wide-decimal's decwide_t
and wide_integer's uintwide_t
.
Boost.Multiprecision is another option with much more interoperability amongh the multiprecision types --- that might be another option, but it might not yet have huge precision if that is what you seek. And Boost tends to have a larger resource footprint than my repos here. (I am also a Boost.Multiprecision co-author/co-maintainer).
If you would like to discuss these matters, or if you have direct questions as you try things or discover bugs I can easily fix or at least try to fix, please feel free to continue this thread.
from wide-decimal.
Great!!!
I'll route to wide-integer + wide-decimal.
I afraid from boost.multiprecision cpp_dec_float in doc say raw "truncate number" with no choose for rounding type,
but boost.multiprecision cpp_int is really good
I'm planning to use arbitrary fixed int and uint to use as 'id' in databases and decimal arbitrary fixed type to compute
and use money values. for decimal fixed point, my consumption dream is some similar at Ada Language 'fixed decimal type' but com more than 18 digits (and in C++20). https://en.wikibooks.org/wiki/Ada_Programming/Types/delta#Decimal_Fixed_Point
And a BigThanks for all your efforts and help!
Thanks,
Best whishes, Daniel
from wide-decimal.
afraid from boost.multiprecision
cpp_dec_float
in doc say raw "truncate number" with no choose for rounding type
Yes. But please do note that the decwide_t
implementation in wide-decimal also has this characteristic. There is rounding on the functions floor, ceil and cast-to-integral-type. But both the Boost decimal type as well as the one in wide-integer do not have complete rounding implemented. I'm pretty sure that Boot.Multiprecision and also wide-decimal will eventually have rounnding on the decimal type, but that's still a ways off at the moment.
In your search for well-behaved decimal numbers, you might also look at cnl from @johnmcfarlane. John do you have a well-behaved decimal type?
from wide-decimal.
See also #49 in this repo
from wide-decimal.
Hi!
This is a really good news!
To exemplify, my main need is a type where I can:
a) set a fixed number of decimal places after the comma.
b) the smallest possible value being 0, 0{decimal places - 1}1 .
c) not limited to 64bit.
eg: 20 digits (comma) 6 digits .
For that I'll create a 20digits (comma) 12digits.
The double digits after comma is to
is to deal with precision and with round. even if it is raw truncated it will still be in
the desired range.
Very thanks for the help,
Best whishes, Daniel.
from wide-decimal.
For that I'll create a 20digits (comma) 12digits
Cool @danieagle. That seems like a good plan. If any further issues arise, please feel free to get back to this issue or create a new one. For the moment, I'll close this.
Thanks for your interest in decwide-t
.
from wide-decimal.
afraid from boost.multiprecision
cpp_dec_float
in doc say raw "truncate number" with no choose for rounding typeYes. But please do note that the
decwide_t
implementation in wide-decimal also has this characteristic. There is rounding on the functions floor, ceil and cast-to-integral-type. But both the Boost decimal type as well as the one in wide-integer do not have complete rounding implemented. I'm pretty sure that Boot.Multiprecision and also wide-decimal will eventually have rounnding on the decimal type, but that's still a ways off at the moment.In your search for well-behaved decimal numbers, you might also look at cnl from @johnmcfarlane. John do you have a well-behaved decimal type?
Hi there. When you can get it to compile, it's generally well behaved: https://godbolt.org/z/WT6K6aT7W
I definitely need more operators to make this user-friendly though.
from wide-decimal.
Hi @ckormanyos and @johnmcfarlane !
Thanks for yours patience and dedication!
I see the updates and tried again.
I getted great success , while not touch the max or min from the setted range, using
cnl with wide_integer port in cnl.
wi_si.cpp.txt
but I yet get funny values when the number reach max or minimum values;
(Whishlist) (pleeaaaaase! :-)
- add round 'nearest to even' (mostly banks use this round type).
- and add some way to detect overflow and underflow.
- (optional) add initialization with strings.
My Sincere Gratitude,
Best wishes, Daniel.
My System:
Linux Ubuntu impish AMD64 g++-11.2.0 cmake-3.18.4 bash-5.1.3
cmdline: g++ -O3 -mtune=native -std=c++20 wi_si.cpp -o Eba1
cmdline: ./Eba1
I am available for testing or whatever is needed.
from wide-decimal.
Hi @danieagle I will keep trying to move forward on implementing rounding for wide-decimal
. This is being tracked in #49.
I have tried a few times and failed. So I'm not quite comprehending all rounding cases and/or algoritmic details. If I get rounding in wide-decimal
, i'll probably import the technology into Boost.Multiprecision and vice versa. But this will take me a while --- if I get it at all.
cnl from @johnmcfarlane is a good place to also keep track of regarding progress on decimal type(s). Formally, John's cnl development is independent of this project, but we are in contact off-and-on regarding related topics.
from wide-decimal.
Related Issues (20)
- Remove C++11 in CI response Boost Math/Multiprecision deprecate C++11 in 2023
- Test decwide_t for edge cases to improve test coverage HOT 1
- String-write crashes for numbers less than 1 with std::fixed flag HOT 1
- Implementation of `frexp()` is wrong/missing
- More function coverage and branch coverage
- Try out codacy report and if it adds value then use it HOT 2
- I/Ostream and to-long-double and 10/12-byte long double refactor HOT 1
- Tune float conversion and get it back on deeply embedded
- Unable to include the math package headers even after building to system(program files) and adding cmake prefix for WideDecimalConfig.cmake HOT 4
- Handle Ubuntu 18.04 Deprecation on GHA
- Use GitHub CodeScanning instead of LGTM
- Handle Ubuntu 18.04 Deprecation on GHA
- Adapt for GCC 13 HOT 2
- valgrind investigations HOT 2
- Add cygwin runner to CI
- Reduce the scope of CI
- C++14 rework HOT 3
- Reduce truncation in multiplication HOT 1
- Try for C++20 `constexpr`-ness
- Repair cygwin in CI and upgrade all CI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wide-decimal.