i have a function that returns a double value (eg. 1.76896558753375)

then i append the value to a QVector<double> with some_vector.append(value)

after append, the value is 1.76897 in the qvector.

why is this happening and how can it be prevented?

stepping through qvector's append function:
Qt Code:
  1. template <typename T>
  2. void QVector<T>::append(const T &t)
  3. {
  4. const T copy(t);
  5. const bool isTooSmall = uint(d->size + 1) > d->alloc;
  6. if (!isDetached() || isTooSmall) {
  7. QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default);
  8. reallocData(d->size, isTooSmall ? d->size + 1 : d->alloc, opt);
  9. }
  10. if (QTypeInfo<T>::isComplex)
  11. new (d->end()) T(copy);
  12. else
  13. *d->end() = copy;
  14. ++d->size;
  15. }
To copy to clipboard, switch view to plain text mode 

both t and copy are the correct un-rounded value until ++d->size, after that line, the rounded value is appended instead of the full value.