P
P
Pavel K2020-08-14 02:48:52
Qt
Pavel K, 2020-08-14 02:48:52

Currency analog from Delphi to Qt?

There is an activex component, which, apparently, was written in Delphi.
I'm trying to use it in Qt (C++). The problem is in the Currency type.
After dumpcpp, the Currency type becomes qlonglong, which loses the fractional part. I changed it to double, but the application occasionally, but swears at the value (what it comes to, alas, it will not be possible to find out).
Perhaps a rounding error, or something is not transmitted correctly. Unfortunately, he did not move in, as the types are eventually given and transmitted.
Tell me, what will be the most competent replacement, so that the fractional part is not discarded and transmitted correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Skusnov, 2020-08-14
@PavelK

The trick here is that the float type (in the broadest sense) points to a fractional floating point number. We are talking about a fractional with a fixed point ( fix-point ). Here it will not be possible to take a format with a mantissa and an order, because the internal representation is binary, not decimal (4 digits). Therefore, you need to take an integer, but process it somewhere (when displaying the results) by dividing by 10 ^ 4.
In automation, often fractional numbers are transmitted as integers, previously multiplied by 10 or 100.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question