0.2 + 0.2 = ?

Intrebari despre limbajul C++, standardul C++, STL, OOP in C++ sau alte subiecte nelegate de VisualC++
Post Reply
User avatar
MarianMMX
Junior
Junior
Posts: 16
Joined: 27 Mar 2014, 09:50
Judet: Galaţi

0.2 + 0.2 = ?

Post by MarianMMX » 20 Aug 2014, 13:07

Ce metode folositi in aplicatii pentru calcule financiare?


If you think C++ is not overly complicated, just what is a
protected abstract virtual base pure virtual private destructor
and when was the last time you needed one? — Tom Cargill (1990)

User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3778
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

Re: 0.2 + 0.2 = ?

Post by Ovidiu Cucu » 30 Aug 2014, 20:09

Daca acuratetea zecimalelor conteaza, o solutie ar fi sa tii numerele pe doi intregi ca, de exemplu, in CURRENCY si sa definesti o clasa gen COleCurrency.
Mai demult, am vazut o aplicatie financiara care tinea numerele "pe stringuri". Ar fi si asta o alternativa de facut calcule in "virgula fixa". Desi banui ca-i mai putin performanta, din cate tin eu minte, nu s-a plans nimeni. :)

Post Reply