Comments (8)
You are correct, but I decided this part needs some rewrite, so it is corrected in a different way.
Overflow issue is corrected, please test with your case.
from decimal_for_cpp.
Thanks, will send tomorrow.
I inherited from your class and had to change the /= operator to use
(inefficient but effective) subtraction because 364.92 / 304.1001 was
coming out with 1.2 and I needed it to be 1.199999.
On Jul 12, 2015 4:40 AM, "vpiotr" [email protected] wrote:
Please provide test values for this issue. I don't see when it can be a
problem.—
Reply to this email directly or view it on GitHub
#13 (comment)
.
from decimal_for_cpp.
using dec::decimal6 as my type
1341.93115 / 10000.000000 was executed and caused me to find the issue
void test_abs(void)
{
dec::int64 resAbs, resllabs;
dec::int64 val = 1341931150L;
resAbs = abs(val);
resllabs = llabs(val);
std::cout << std::endl << " test_abs starting" << std::endl;
std::cout << "val : " << val << ", abs(): " << resAbs << ", llabs(): "
<< resllabs << std::endl;
val = 10000000000;
resAbs = abs(val);
resllabs = llabs(val);
std::cout << "val : " << val << ", abs(): " << resAbs << ", llabs(): "
<< resllabs << std::endl;
std::cout << std::endl << " test_abs finished" << std::endl;
std::cout << std::endl;
return;
}
test_abs starting
val : 1341931150, abs(): 1341931150, llabs(): 1341931150
val : 10000000000, abs(): 1410065408, llabs(): 10000000000
test_abs finished
exiting....
$ g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
On Sun, Jul 12, 2015 at 12:50 PM, Bob Weidman [email protected] wrote:
Thanks, will send tomorrow.
I inherited from your class and had to change the /= operator to use
(inefficient but effective) subtraction because 364.92 / 304.1001 was
coming out with 1.2 and I needed it to be 1.199999.
On Jul 12, 2015 4:40 AM, "vpiotr" [email protected] wrote:Please provide test values for this issue. I don't see when it can be a
problem.—
Reply to this email directly or view it on GitHub
#13 (comment)
.
from decimal_for_cpp.
Please test with most recent version. For the first pair of values, correct result is in fact 1.2 (with rounding to 6 decimal places).
Without rounding result is equal to:
364.92 / 304.1001 = 1,1999996053930926033894760310832
from decimal_for_cpp.
yes the answer is coming out 1.2.
I'm reading code now to see where the rounding is taking place. I need to
emulate the division without the rounding taking place.
The program does rounding or truncation of digits to right of the decimal
place at various locations - meaning at specific times. (Wants to retain
the values as is until rounding or truncation of digits is desired.)
On Mon, Jul 13, 2015 at 5:26 AM, vpiotr [email protected] wrote:
Please test with most recent version. For the first pair of values,
correct result is in fact 1.2 (with rounding to 6 decimal places).Without rounding result is equal to:
364.92 / 304.1001 = 1,1999996053930926033894760310832—
Reply to this email directly or view it on GitHub
#13 (comment)
.
from decimal_for_cpp.
Currently you can switch off rounding for all class instances by the following steps:
- define DEC_EXTERNAL_ROUND
- define own round() function which simply performs cast
- modify multDiv() function in no-overflow section
I suppose it can be useful if I define rounding as a policy for this class, you can expect easier solution in the near future.
from decimal_for_cpp.
See BOOST_AUTO_TEST_CASE(decimalNoRoundPolicy) for no-rounding mode.
from decimal_for_cpp.
Sorry for delay...
Trying to download this and will test.
Thanks for incorporating my change requests.
On Jul 15, 2015 9:55 AM, "vpiotr" [email protected] wrote:
See BOOST_AUTO_TEST_CASE(decimalNoRoundPolicy) for no-rounding mode.
—
Reply to this email directly or view it on GitHub
#13 (comment)
.
from decimal_for_cpp.
Related Issues (20)
- Problem with overflow detection with CLANG compiler.. HOT 1
- incorrect constructing from fp HOT 5
- How does it stand against Muller's recursion ? HOT 2
- specify decimal separator HOT 2
- Make it fully trivial HOT 3
- Suggest using constexpr HOT 1
- Is it compatible with IEEE 754-2008? HOT 2
- Modulo operator HOT 2
- is there a way to perform assigment from std::string? HOT 1
- how to get an int/double from dec type ? HOT 3
- signal SIGSEGV, Segmentation fault on return HOT 2
- Still C++11 stuff when DEC_NO_CPP11 is defined HOT 1
- format_from_stream truncates its return value from decimal_format to basic_decimal_format HOT 3
- Enhancement: More friendly constructor HOT 1
- support for power and root ? HOT 1
- Edge cases failing HOT 1
- how to initialize in struct declaration HOT 4
- Need support to wstring HOT 1
- macos build is failing HOT 1
- unable to change precision of existing variable HOT 3
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 decimal_for_cpp.