GithubHelp home page GithubHelp logo

qdecimal's People

Contributors

dalins avatar semihc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qdecimal's Issues

QDecNumber::toDouble() rounding defect


Reported by Aleksey Sukhonosov:

Please, take a look at the code:

    QDecNumber i;
    i.fromString("1.125");
    qDebug()<<i.toString()<<"~"<<QString::number(i.toDouble(),'f',2)<<" or "<<QString::number(QString("1.125").toDouble(),'f',2)<<" or "<<QString::number(QString(i.toString()).toDouble(),'f',2);
    i.fromString("1.375");
    qDebug()<<i.toString()<<"~"<<QString::number(i.toDouble(),'f',2)<<" or "<<QString::number(QString("1.375").toDouble(),'f',2)<<" or "<<QString::number(QString(i.toString()).toDouble(),'f',2);

The output should contain an original number and this number having been 
rounded. Every rounding method is supposed to give the same result. But in 
debug I have:

"1.125" ~ "1.00"  or  "1.12"  or  "1.12" 
"1.375" ~ "1.00"  or  "1.38"  or  "1.38" 

So, it seems that QDecNumber::toDouble() works in a wrong way, as everything it 
returns is of integer value (though, of double type).

Original issue reported on code.google.com by [email protected] on 29 Jan 2012 at 12:29

A comment maybe it's not right

In
     int QDecNumberTests::opTest(const QStringList& tokens)    
it says
    /* Uncomment to receive more information about passing test cases: */
but it seems there is nothing to uncomment. Is this way?    

Thanks for QDecimal! 

Original issue reported on code.google.com by [email protected] on 10 Aug 2013 at 5:26

"1 + QDecDouble" causes an odd result without warnings

> What steps will reproduce the problem?

I compiled
      QDecDouble num("0.1");
      QDecDouble aux = 1 + num;
      cout << aux << endl;
and the result was
        8.19999E-393
which is very close to zero, which is not adequate. 

However, I compiled 
        double num(0.1);
        double aux = 1 + num;
        cout << aux << endl;
and the result was 
        1.1
which is correct. I obtained the same result using "qreal" instead of "double", 
of course.

> What version of the product are you using? On what operating system?
QDecimal 1.0.1. Kubuntu 13.04.

Thanks for QDecimal! 

Original issue reported on code.google.com by [email protected] on 10 Aug 2013 at 5:48

An "unused parameters" warning

When compiling Main.cc, `gcc` emits a warning about
    void MessageOutput(QtMsgType type, const QMessageLogContext &context,
                        const QString &msg)
and its variable "context" that is never used. 

That puzzles the developers ("A warning?" "What's happening?" "Is QDecimal well 
done?" "Should I solve it?" "Can I solve it?" "Should I file a bug?"). I read 
<http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html> and added 
three "pragmas" in my local QDecimal copy, this way:

    [...]
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wunused-parameter"
    void MessageOutput(QtMsgType type, const QMessageLogContext &contexte,
                        const QString &msg)
    {

    QByteArray lmsg = msg.toLocal8Bit();
    const char* cmsg = lmsg.constData();
    switch (type) {
        case QtDebugMsg:
        fprintf(stderr, "%s\n", cmsg);
        break;
        case QtWarningMsg:
        fprintf(stderr, "Warn: %s\n", cmsg);
        break;
        case QtCriticalMsg:
        fprintf(stderr, "Critical: %s\n", cmsg);
        break;
        case QtFatalMsg:
        fprintf(stderr, "Fatal: %s\n", cmsg);
        abort();
    }
    }
    #pragma GCC diagnostic pop
    [...]

and this way `gcc` doesn't warn about "unused parameters", but probably you'll 
have a better solution to avoid warning developers (`gcc` ones, at least).

Thanks for QDecimal! 

Original issue reported on code.google.com by [email protected] on 10 Aug 2013 at 5:30

QDecNumber fails to construct value of DBL_MAX or DBL_MIN

What steps will reproduce the problem?
1. Attempt to instantiate a QDecNumber object from DBL_MAX double value.

QDecNumber decNum(DBL_MAX);

2. Compile and run program.

What is the expected output?

1.7976931348623158e+308

What do you see instead?

Program crashes.

What version of the product are you using? On what operating system?

1.0.0

Please provide any additional information below.

The problem stems from the fact that MaxStrSize is too small to accommodate all 
representable doubles in the 'f' format specified in sprintf(str,'%f',d) in 
fromDouble.  Changing the format specifier to '%.16e' seems to resolve the 
issue, the only downside being the forced precision of 16 decimal digits when 
that might not always be the desired precision.

Original issue reported on code.google.com by [email protected] on 11 Jul 2012 at 4:15

Can't Compile under Microsoft Visual Studio Express 2012 for Windows De3sktop

What steps will reproduce the problem?
1. Type nmake in any directory and receive error msg
"NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop."
2. Type nmake *.pri or *.pro and all one receives is errors,
generally of the form "Too many names to left of =" wherever a +=
token appears.

What is the expected output? What do you see instead?
Trying to compile under MS VCC; nothing happens.

What version of the product are you using? 
Product: Microsoft Visual Studio Express 2012 for Windows Desktop
O/S: Windows 8

Please provide any additional information below.
In trying to compile "Example 1" under MS Viual Studio Express 2012 I get these 
5 errors:
Error   14  error LNK2001: unresolved external symbol "struct decContext * __cdecl 
decContextDefault(struct decContext *,int)" 
(?decContextDefault@@YAPAUdecContext@@PAU1@H@Z) 

Error   15  error LNK2001: unresolved external symbol "struct decNumber * __cdecl 
decNumberFromString(struct decNumber *,char const *,struct decContext *)" 
(?decNumberFromString@@YAPAUdecNumber@@PAU1@PBDPAUdecContext@@@Z)

Error   16  error LNK2001: unresolved external symbol "struct decNumber * __cdecl 
decNumberAdd(struct decNumber *,struct decNumber const *,struct decNumber const 
*,struct decContext *)" 
(?decNumberAdd@@YAPAUdecNumber@@PAU1@PBU1@1PAUdecContext@@@Z)

Error   17  error LNK2001: unresolved external symbol "char * __cdecl 
decNumberToString(struct decNumber const *,char *)" 
(?decNumberToString@@YAPADPBUdecNumber@@PAD@Z)

Error   18  error LNK1120: 4 unresolved externals

Original issue reported on code.google.com by [email protected] on 24 Jul 2013 at 10:07

QDecDouble::MaxStrSize too small

256 bytes is not enough to represent a double number of DBL_MAX or DBL_MIN

try this,

int main(int argc, char *argv[])
{    
    double d = DBL_MAX;
    QDecDouble dd(d);
}

and see the application happily crash.


Original issue reported on code.google.com by [email protected] on 17 Jan 2012 at 2:24

Rounding Problem

Hello
I got the following problem:
I coudent figure out how to round after a callculation with the QDecDouble Type.
This is my code:
QDecDouble test(12.0003); QDecContext con; con.setDigits(4); con.setRound(DEC_ROUND_HALF_UP); test = test.add(QDecDouble(12.0003),&con); //result of the calculation is 24.0006, expectet result after rounding is 24.0010 but result still the same (24.0006)

i don't see the problem.
Thx for the help its very appriciatet and thx very mutch for QDecimal.

Regards Sascha

mingw32-make fails to compile the code

What steps will reproduce the problem?
1. Qmake -r
2. mingw32-make


What is the expected output? What do you see instead?
Compiled library

What version of the product are you using? On what operating system?
QT4.8 command prompt

Please provide any additional information below.

g++: /Zc:forScope: No such file or directory
g++: /Zc:wchar_t: No such file or directory
g++: /RTC1: No such file or directory
mingw32-make[2]: *** [debug/QDecContext.o] Error 1
mingw32-make[2]: Leaving directory `D:/Lähdekoodeja/qdecimal/src'
mingw32-make[1]: *** [debug] Error 2
mingw32-make[1]: Leaving directory `D:/Lähdekoodeja/qdecimal/src'
mingw32-make: *** [sub-src-make_default-ordered] Error 2

Original issue reported on code.google.com by [email protected] on 14 Apr 2014 at 7:10

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.